0

背景: 文字列と double が混在する csv ファイルから読み込もうとしています。検索とインデックス作成の目的で文字列をそのままにしておきたいのですが、リスト内の double 値でデータ分析を実行できるようにしたいと考えています。また、csv ファイル全体を別のカテゴリに分ける前にメモリに読み込みたくないので、csv から読み込まれるカスタム データ型のリストに割り当てようとしています。

その単一のリストエントリを double にキャストしてからリストに追加するにはどうすればよいですか?

class data
{
    public List<string> timefrom { get; set; }
    public List<string> timeto { get; set; }
    public List<string> type { get; set; }        
    public List<string> site { get; set; }
    public List<string> box { get; set; }
    public List<string> group { get; set; }        
    public List<string> sourcecopy { get; set; }
    public List<string> destcopy { get; set; }
    public List<string> gridid { get; set; }        
    public List<string> stat { get; set; }
    public List<double> value { get; set; }
    public List<string> unit { get; set; }
    public List<string> peak { get; set; }
}

class Class1
{
    public List<data> 
        WANtpfromSite, 
        WANtpbyCG, 
        IncomingWritesbyCG, 
        LinkUtilbyCG, 
        BoxUtil, 
        CompressionCPU, 
        ReplicationCPU, 
        CompressionRatio, 
        DeduplicationRatio, 
        IncomingWritesbyBox, 
        IncomingWritesbyBoxReplicating, 
        IObyBox, 
        IObyBoxReplicating, 
        PacketLoss, 
        LineLatency;


    public void getDayData(string directory)
    {

        string[] fileEntries;

        fileEntries = System.IO.Directory.GetFiles(directory + "/home/www/info/long_term_stats");
        string filePath = fileEntries[0];
        System.IO.StreamReader sr = new System.IO.StreamReader(filePath);
        List<string> Line;
        int row = 1;
        while (!sr.EndOfStream)
        {
            //Splits the line read into a list of string values
            Line = sr.ReadLine().Split(',').ToList<string>();

            // Here I'll probably use a switch case to set the variable, but this is an example of what it should do.
            if (Line[8] == "Wan Throughput from site")
            {
                //Here is where I'm having the problem - it can't implicitely convert the string list to a data list because
                // of that single double value within the list.  How would I go about explicitely converting the "Line" 
                //variable to a <data> type?

                WANtpfromSite = List < data > datatype;
            }
            row++;

        }

    }
4

1 に答える 1