wireservice / csvkit

A suite of utilities for converting to and working with CSV, the king of tabular file formats.
https://csvkit.readthedocs.io
MIT License
6.03k stars 603 forks source link

make csvlook fail with errcode > 0 when header and table have mismatched number of columns #1210

Closed gl-yziquel closed 1 year ago

gl-yziquel commented 1 year ago

Currently, when a csv file has a mismatched header with a different number of values from the number of columns in the csv table, the program fails with

ValueError: Row 0 has 12 values, but Table only has 8 columns.

However, it does not exit with an error code. As I am scripting this from a command runner, I'd appreciate a nonzero error code being returned to the shell.

gl-yziquel commented 1 year ago

Suggested PR: https://github.com/wireservice/csvkit/pull/1211

jpmckinney commented 1 year ago

However, it does not exit with an error code.

It does for me?

$ csvlook examples/bad.csv
ValueError: Row 0 has 4 values, but Table only has 3 columns.
$ echo $?
1