Creating a DataTable from CSV File

前端 未结 5 2080
野趣味
野趣味 2020-12-10 06:59

I\'m working on a project and I need to read a CSV file and then fill a DataSet with its data. I\'ve been searching and I have found some interesting things in OleDB.

5条回答
  •  天命终不由人
    2020-12-10 07:45

    KBCsv has built-in support for reading into a DataSet:

    using (var reader = new CsvReader(@"C:\data.csv")) {
        reader.ReadHeaderRecord();
        var dataSet = new DataSet();
        reader.Fill(dataSet, "csv-data");
    }
    

提交回复
热议问题