I am writing a CSV parser and I want it to comply with this standards. It states:
- Each record is located on a separate line, delimited by a line break (CRLF)
How should I handle rows ending with only CR
of LF
character? Should I treat them as literals and pass to field, interpret as a row end. Or maybe dub the file malformed?
I guess, that most flexible solution would be to accept either type of line end, but I am trying to figure out what standards say.
What do you think about it?
You should certainly not treat them as malformed, because there can be different line endings on Linux, Windows and Mac for example.
It's better to support them all.
Also, fields can have newlines in them as well, if they are properly quoted. So you'll need to check for that too.
For example:
is a valid csv row.