News for hackers. Stuff that matters.
Re:Friends don't let friends export to CSV by nradov on Monday March 25, 2024 @07:35PM (#39822522)
If both parties implement RFC 4180 and use a consistent character set encoding then I don't think there are actually any undefined behaviors. But in practice a lot of implementations are simply broken, including those from major tech companies that ought to know better.
Re:Friends don't let friends export to CSV by senknvd on Monday March 25, 2024 @08:48PM (#39823076)
I don't think RFC 4180 differentiates between an empty string and a null value. As long as you add a check that all string columns are free of empty values before writing you should be good.

I think in polars it's

    df.filter(pl.col(pl.Utf8).str.len_bytes() == 0).shape[0] == 0
although there's probably a better way to write this.
Re:Friends don't let friends export to CSV by nradov on Monday March 25, 2024 @09:36PM (#39823424)
Well I would consider differentiation between empty string versus null as simply being out of scope for CSV rather than undefined behavior. It was never intended as a complete database dump format.
Re:Friends don't let friends export to CSV by thayne on Monday March 25, 2024 @09:45PM (#39823459)
And the application doesn't try to convert the cells into non-string data types like numbers, dates, etc.
Re:Friends don't let friends export to CSV by nradov on Monday March 25, 2024 @09:54PM (#39823520)
Converting strings into other data types is out of scope for CSV, not really undefined behavior. The type conversions happen at a later stage of the import process.
Re:Friends don't let friends export to CSV by thayne on Monday March 25, 2024 @11:17PM (#39823979)
It's out of scope for the RFC, but it could still be undefined behavior for the import/export process.