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
5.9k stars 605 forks source link

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

Closed gl-yziquel closed 8 months ago

gl-yziquel commented 9 months 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 9 months ago

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

jpmckinney commented 9 months 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