Parsing .csv file into 2d array

后端 未结 5 1485
我寻月下人不归
我寻月下人不归 2021-02-08 01:20

I\'m trying to parse a CSV file into a 2D array in C#. I\'m having a very strange issue, here is my code:

string filePath = @\"C:\\Users\\Matt\\Desktop\\Eve Spre         


        
5条回答
  •  时光说笑
    2021-02-08 02:10

    This is the same as posted by Pavel, but it ignores empty lines that may cause your program to crash.

    var filePath = @"C:\Users\Matt\Desktop\Eve Spread Sheet\Auto-Manufacture.csv";
    
    string[][] data = File.ReadLines(filepath).Where(line => line != "").Select(x => x.Split('|')).ToArray();
    

提交回复
热议问题