Visidata: CSV files are saved with DOS line endings

Created on 10 Nov 2019  路  2Comments  路  Source: saulpw/visidata

Small description
When I load a CSV file with unix (\n) line endings into vd and save it, it's written over with DOS (\r\n) line endings, and I have to use a tool like dos2unix after every save to normalize it.

Expected result
I think it should either preserve the line ending format of the original file that was loaded.

Additional context
Happens with v1.3, v1.5, and v2.-1dev.

bug

Most helpful comment

I think that \r\n is the standard for CSV:

https://tools.ietf.org/html/rfc4180

In this way you could manage carriage return inside cells (\n).

All 2 comments

Hi @dbandstra!

Yeah, his is happening DOS line endings are the default for the Python csv writer.

VisiData passes a few options to the csv writer. Something I can do for now is add lineterminator to those. This would mean that you could configure which lineterminator you wanted for a particular session, by passing the command line argument --csv-lineterminator $'\n' or set a new default for all sessions in your ~/.visidatarc with options.csv_lineterminator = '\n'.

I think that \r\n is the standard for CSV:

https://tools.ietf.org/html/rfc4180

In this way you could manage carriage return inside cells (\n).

Was this page helpful?
0 / 5 - 0 ratings