Which delimiter should be used for lists of values inside a CSV file?

Asked
Viewd1175

3

I have a CSV file that has lists of values for some fields. They're stored in the database as HTML "ul" elements, but I want to convert them into something more spreadsheet-friendly.

What should I use as my delimiter? I could use escaped commas, pipes, semicolons, or pretty much anything else. Is there some kind of de facto standard people use for this?

1175

4 个答案

4

项目周围的报价是为此

 123, hello, "a, b, c, d", 29
 
  • This is the solution I went with.

    RafeSeptember 04, 2009 04:42
  • No-one is ever looking at CSV’s (in the raw format) are they? Something like excel will break it out appropriately (well, pending bugs, which it has had).

    Noon SilkAugust 19, 2009 14:26
  • This was one of the possibilities I considered. I think commas are the most logical internal delimiter. The only downside is that this approach may make the CSV file confusing to look at.

    RafeAugust 19, 2009 14:21
1

我一直喜欢TAB字符作为分隔符-导入Excel时也很好用。

2

带有引号作为文本限定符的管道最适合我。当您在NotePad ++中打开数据文件时,它也使读取变得更容易。

1

这在很大程度上取决于您尝试分离的值。例如,如果期望数值,则使用逗号或句点作为分隔符是不明智的。如果值预期为散列,则结果相同。或管道

使用在内容中使用可能性最小的字符。为此,您可能需要先分析数据,以便轻松确定要使用的定界符。