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

前端 未结 4 1284
孤城傲影
孤城傲影 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"];
        }
    }
    
    0 讨论(0)
  • 2021-01-20 19:15

    As mentioned by dendarii, the CSV separator that Excel uses is determined by your regional settings, specifically the 'list separator' character. (And Excel does this erroneously in my opinion, as it is called a comma seperated file)

    HOWEVER, if that still does not solve your issue, there is another possible complication:

    Check your 'digit grouping' character and ensure that is NOT a comma.

    Excel appears to revert back to semicolon when exporting decimal numbers and has digit grouping also set to a comma. Setting the digit grouping to a full stop / period (.) solved this for me.

    0 讨论(0)
  • 2021-01-20 19:18
    • Solution for German Windows 10:

    • Mention to change the decimal separator to . and maybe thousands separators to (thin space) as well.

    Can't believe this is true...Comma-separated values are separated by semicolon?

    0 讨论(0)
  • 2021-01-20 19:31

    Check what delimiter is specified on your computer. Control Panel > Regional and Language Options > Regional Options tab - click Customize button. There's an option there called "List separator". I suspect this is set to semi-colon.

    0 讨论(0)
提交回复
热议问题