CSVCLEAN(1) csvkit CSVCLEAN(1) (NAME) csvclean - CSV (DESCRIPTION) CSV . (Checks) o --length-mismatch . o --empty-columns . : --enable-all-checks (-a). (Fixes) o CSV ( ) : id,address,country 1,1 Main St Springfield,US 2,123 Acadia Avenue London,GB --join-short-rows : id,address,country 1,"1 Main St Springfield",US 2,"123 Acadia Avenue London",GB --separator . --separator ", ": id,address,country 1,"1 Main St, Springfield",US 2,"123 Acadia Avenue, London",GB o CSV : id,name,country 1,Alice 2,Bob,CA --fill-short-rows : id,name,country 1,Alice, 2,Bob,CA : csvcut ! --fillvalue . --fillvalue "US": id,name,country 1,Alice,US 2,Bob,CA : --header-normalize-space (Usage). : csvkit : o --quoting (-u) o --delimiter (-d) --tabs (-t) o LF ( \n) o (double-quotation mark) --quotechar (-q) o UTF-8 --encoding (-e) (Output) csvclean . : o --omit-error-rows . . o (stderr) . . (Usage) usage: csvclean [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b] [-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-S] [-H] [-K SKIP_LINES] [-v] [-l] [--zero] [-V] [FILE] Fix common errors in a CSV file. positional arguments: FILE The CSV file to operate on. If omitted, will accept input as piped data via STDIN. optional arguments: -h, --help show this help message and exit --length-mismatch Report data rows that are shorter or longer than the header row. --empty-columns Report empty columns as errors. -a, --enable-all-checks Enable all error reporting. --omit-error-rows Omit data rows that contain errors, from standard output. --label LABEL Add a "label" column to standard error. Useful in automated workflows. Use "-" to default to the input filename. --header-normalize-space Strip leading and trailing whitespace and replace sequences of whitespace characters by a single space in the header. --join-short-rows Merges short rows into a single row. --separator SEPARATOR The string with which to join short rows. Defaults to a newline. --fill-short-rows Fill short rows with the missing cells. --fillvalue FILLVALUE The value with which to fill short rows. Defaults to none. : . (EXAMPLES) : $ csvclean examples/bad.csv 2> errors.csv column_a,column_b,column_c 0,mixed types.... uh oh,17 $ cat errors.csv line_number,msg,column_a,column_b,column_c 1,"Expected 3 columns, found 4 columns",1,27,,I'm too long! 2,"Expected 3 columns, found 2 columns",,I'm too short! : (,) . csvclean CSV CSV - . : $ csvclean --empty-columns examples/test_empty_columns.csv 2> errors.csv a,b,c,, a,,,, ,,c,, ,,,, $ cat errors.csv line_number,msg,a,b,c,, 1,"Empty columns named 'b', '', ''! Try: csvcut -C 2,4,5",,,,, csvcut : $ csvcut -C 2,4,5 examples/test_empty_columns.csv a,c a, ,c , LF ( \n) CRLF ( \r\n) : csvformat -M $'\r\n' examples/dummy.csv (AUTHOR) Christopher Groskopf (COPYRIGHT) 2016, Christopher Groskopf and James McKinney 2.2.0 16 2024 CSVCLEAN(1)