vincentlaucsb / csv-parser

A high-performance, fully-featured CSV parser and serializer for modern C++.
MIT License
864 stars 144 forks source link

Fields with embedded newlines #221

Closed melton1968 closed 1 month ago

melton1968 commented 3 months ago

I am loading a csv file produced by PostgreSQL. Some of the fields have embedded newlines:

abc,"def\nghi",123,
xyz,"rst\nuvw",456,

Should the parser handle this case?

It complains that the row has to few columns.

vincentlaucsb commented 3 months ago

image

Yes it should. The warning is probably because of the trailing comma after every row.

vincentlaucsb commented 1 month ago

Added some unit tests and verified that embedded newline handling works, even when the last row is empty.

With that being said, my experience with PostgreSQL and it's COPY TO CSV function is that it works very well and does not produce empty columns at the end.

Closing as I'm not sure what there is to fix.