RFC4180: CSVファイルフォーマット
CSVファイルフォーマットにもRFCがあったのね。というか、October 2005 に作られたばっかりみたい。
Surprisingly, while this format is very common, it has never been formally documented.
まあ、改行コードは CRLF にしろとか、その他のあたりまえなところはいいとして、この辺は要チェックかも。
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"
つまり、フィールド内に改行を含む場合はダブルクォートで囲めとか、フィールド内にダブルクォートを含むときは、もうひとつのダブルクォートでエスケープしろ、とか。
ずいぶん前にCSVParser のコードを書いたのを思い出した。