jupyterlab-contrib / jupyterlab-spreadsheet-editor

JupyterLab spreadsheet editor for tabular data (e.g. csv, tsv)
BSD 3-Clause "New" or "Revised" License
135 stars 7 forks source link

Extra row added when saving a csv #57

Open marberts opened 1 year ago

marberts commented 1 year ago

Description

Saving a csv prepared with R or pandas adds an extra row at the bottom. That is, a csv like

a,b
1,3
2,4

becomes

a,b
1,3
2,4
,    <-- added

Reproduce

Make a csv with R (or pandas).

Rscript -e "write.csv(data.frame(a = 1:2, b = 3:4), row.names = FALSE, eol = '\r\n')" > test.csv

Then open test.csv in JupyterLab, modify the content of a cell, and save.

Removing the line ending on the last line before opening in JupyterLab seems to fix it, but having a CRLF at the end of the last row is allowed by RFC 4180. That is,

cat -e test.csv

a,b^M$
1,3^M$
2,4^M$

results in an extra line, whereas

cat -e test.csv

a,b^M$
1,3^M$
2,4

works as expected.

Expected behavior

I expect no extra row added when saving a csv.

Context