Reading data from a CSV to an array of arrays (C#)

前端 未结 2 511
攒了一身酷
攒了一身酷 2021-01-28 03:13

I have the CSV file opened, but I can\'t figure out how to put the resultant array from splitting the line into another array. I have the following code currently, hopefully it

2条回答
  •  醉梦人生
    2021-01-28 03:44

    As a supplemental answer for the means of producing a list, here is what I was able to get to work:

      List rows = MyCSVString.Replace("\n", "").Split('\r').ToList();
      List> listedMatrix = new List>();
      foreach(var x in rows)
      {
        if(x != "")
        {
          var rowList = x.Split(',').ToList();
          listedMatrix.Add(rowList);
        }
      }
    
    • yea, commas will mess it up, as this isn't really true parsing.

提交回复
热议问题