CSV is actually … Semicolon Separated Values … (Excel export on AZERTY)

前端 未结 4 1318
孤城傲影
孤城傲影 2021-01-20 18:38

I\'m a bit confused here.

When I use Excel 2003 to export a sheet to CSV, it actually uses semicolons ...

Col1;Col2;Col3
shfdh;dfhdsfhd;fdhsdfh
dgsgs         


        
4条回答
  •  無奈伤痛
    2021-01-20 19:12

    One way would be to just use a decent CSV library; one that lets you specify the delimiter:

    using (var csvReader = new CsvReader("yourinputfile.csv"))
    {
        csvReader.ValueSeparator = ';';
        csvReader.ReadHeaderRecord();
    
        while (csvReader.HasMoreRecords)
        {
            var record = csvReader.ReadDataRecord():
            var col1 = record["Col1"];
            var col2 = record["Col2"];
        }
    }
    

提交回复
热议问题