CSV 也是“字符分隔值”,而不仅仅是逗号。
您可以使用任何字符作为分隔符,但tab
or\t
被广泛用于此,因为它通常不用于用户输入。
CSV 的 RFC 是RFC 4180
它建议使用数据字段和字段分隔符。这里是原文,请注意(5)中Microsoft Excel的特殊部分
5. Each field may or may not be enclosed in double quotes (however
some programs, such as Microsoft Excel, do not use double quotes
at all). If fields are not enclosed with double quotes, then
double quotes may not appear inside the fields. For example:
"aaa","bbb","ccc" CRLF
zzz,yyy,xxx
6. Fields containing line breaks (CRLF), double quotes, and commas
should be enclosed in double-quotes. For example:
"aaa","b CRLF
bb","ccc" CRLF
zzz,yyy,xxx
7. If double-quotes are used to enclose fields, then a double-quote
appearing inside a field must be escaped by preceding it with
another double quote. For example:
"aaa","b""bb","ccc"
另请注意,Excel 开箱即用地识别 Tab