Reading CSV file and storing values into an array

后端 未结 19 1438
猫巷女王i
猫巷女王i 2020-11-22 06:35

I am trying to read a *.csv-file.

The *.csv-file consist of two columns separated by semicolon (\";\").

I am able

19条回答
  •  终归单人心
    2020-11-22 06:54

    I have been using csvreader.com(paid component) for years, and I have never had a problem. It is solid, small and fast, but you do have to pay for it. You can set the delimiter to whatever you like.

    using (CsvReader reader = new CsvReader(s) {
        reader.Settings.Delimiter = ';';
        reader.ReadHeaders();  // if headers on a line by themselves.  Makes reader.Headers[] available
        while (reader.ReadRecord())
            ... use reader.Values[col_i] ...
    }
    

提交回复
热议问题