1CSVCLEAN(1) csvkit CSVCLEAN(1)
2
3
4
6 csvclean - csvclean Documentation
7
9 Cleans a CSV file of common syntax errors:
10
11 • reports rows that have a different number of columns than the header
12 row
13
14 • attempts to correct the CSV by joining short rows into a single row
15
16 Note that every csvkit tool does the following:
17
18 • removes optional quote characters, unless the –quoting (-u) option is
19 set to change this behavior
20
21 • changes the field delimiter to a comma, if the input delimiter is set
22 with the –delimiter (-d) or –tabs (-t) options
23
24 • changes the record delimiter to a line feed (LF or \n)
25
26 • changes the quote character to a double-quotation mark, if the char‐
27 acter is set with the –quotechar (-q) option
28
29 • changes the character encoding to UTF-8, if the input encoding is set
30 with the –encoding (-e) option
31
32 Outputs [basename]_out.csv and [basename]_err.csv, the former contain‐
33 ing all valid rows and the latter containing all error rows along with
34 line numbers and descriptions:
35
36 usage: csvclean [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b]
37 [-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-S] [-H]
38 [-K SKIP_LINES] [-v] [-l] [--zero] [-V] [-n]
39 [FILE]
40
41 Fix common errors in a CSV file.
42
43 positional arguments:
44 FILE The CSV file to operate on. If omitted, will accept
45 input on STDIN.
46
47 optional arguments:
48 -h, --help show this help message and exit
49 -n, --dry-run Do not create output files. Information about what
50 would have been done will be printed to STDERR.
51
52 See also: ../common_arguments.
53
55 Test a file with known bad rows:
56
57 csvclean -n examples/bad.csv
58
59 Line 1: Expected 3 columns, found 4 columns
60 Line 2: Expected 3 columns, found 2 columns
61
62 To change the line ending from line feed (LF or \n) to carriage return
63 and line feed (CRLF or \r\n) use:
64
65 csvformat -M $'\r\n' examples/dummy.csv
66
68 Christopher Groskopf
69
71 2021, Christopher Groskopf
72
73
74
75
761.0.4 Jan 27, 2021 CSVCLEAN(1)