You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a \n at the end of a .csv or .tsv file shouldn't cause a crash.
Github for example asks for all files to end in an empty line, otherwise it will show a red stop sign.
In any case, if you want to enforce no empty lines at end, then the error should be caught and handled, before telling the user what the problem is.
How to reproduce
printf"a,b,c\n1,2,3\n\n">a.csv
csv-diff a.csv a.csv --key a
Traceback (most recent call last):
File "/usr/local/Caskroom/mambaforge/base/bin/csv-diff", line 8, in <module>
sys.exit(cli())
File "/usr/local/Caskroom/mambaforge/base/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "/usr/local/Caskroom/mambaforge/base/lib/python3.9/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/usr/local/Caskroom/mambaforge/base/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/Caskroom/mambaforge/base/lib/python3.9/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/usr/local/Caskroom/mambaforge/base/lib/python3.9/site-packages/csv_diff/cli.py", line 60, in cli
diff = compare(load(previous), load(current), show_unchanged)
File "/usr/local/Caskroom/mambaforge/base/lib/python3.9/site-packages/csv_diff/cli.py", line 56, in load
return load_csv(
File "/usr/local/Caskroom/mambaforge/base/lib/python3.9/site-packages/csv_diff/__init__.py", line 26, in load_csv
return {keyfn(r): r for r in rows}
File "/usr/local/Caskroom/mambaforge/base/lib/python3.9/site-packages/csv_diff/__init__.py", line 26, in <dictcomp>
return {keyfn(r): r for r in rows}
File "/usr/local/Caskroom/mambaforge/base/lib/python3.9/site-packages/csv_diff/__init__.py", line 21, in <lambda>
keyfn = lambda r: r[key]
KeyError: 'a'
The error should be much better, saying which line the error is on, etc.
The text was updated successfully, but these errors were encountered:
Having a
\n
at the end of a.csv
or.tsv
file shouldn't cause a crash.Github for example asks for all files to end in an empty line, otherwise it will show a red stop sign.
In any case, if you want to enforce no empty lines at end, then the error should be caught and handled, before telling the user what the problem is.
How to reproduce
The error should be much better, saying which line the error is on, etc.
The text was updated successfully, but these errors were encountered: