Dealing with commas in a CSV file

后端 未结 27 2752
傲寒
傲寒 2020-11-21 06:53

I am looking for suggestions on how to handle a csv file that is being created, then uploaded by our customers, and that may have a comma in a value, like a company name.

27条回答
  •  鱼传尺愫
    2020-11-21 07:28

    In Europe we have this problem must earlier than this question. In Europe we use all a comma for a decimal point. See this numbers below:

    | American      | Europe        |
    | ------------- | ------------- |
    | 0.5           | 0,5           |
    | 3.14159265359 | 3,14159265359 |
    | 17.54         | 17,54         |
    | 175,186.15    | 175.186,15    |
    

    So it isn't possible to use the comma separator for CSV files. Because of that reason, the CSV files in Europe are separated by a semicolon (;).

    Programs like Microsoft Excel can read files with a semicolon and it's possible to switch from separator. You could even use a tab (\t) as separator. See this answer from Supper User.

提交回复
热议问题