1CSVCUT(1)                           csvkit                           CSVCUT(1)
2
3
4

NAME

6       csvcut - csvcut Documentation
7

DESCRIPTION

9       Filters  and  truncates CSV files. Like the Unix “cut” command, but for
10       tabular data:
11
12          usage: csvcut [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b]
13                        [-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-S] [-H]
14                        [-K SKIP_LINES] [-v] [-l] [--zero] [-V] [-n] [-c COLUMNS]
15                        [-C NOT_COLUMNS] [-x]
16                        [FILE]
17
18          Filter and truncate CSV files. Like the Unix "cut" command, but for tabular
19          data.
20
21          positional arguments:
22            FILE                  The CSV file to operate on. If omitted, will accept
23                                  input on STDIN.
24
25          optional arguments:
26            -h, --help            show this help message and exit
27            -n, --names           Display column names and indices from the input CSV
28                                  and exit.
29            -c COLUMNS, --columns COLUMNS
30                                  A comma separated list of column indices, names or
31                                  ranges to be extracted, e.g. "1,id,3-5". Defaults to
32                                  all columns.
33            -C NOT_COLUMNS, --not-columns NOT_COLUMNS
34                                  A comma separated list of column indices, names or
35                                  ranges to be excluded, e.g. "1,id,3-5". Defaults to no
36                                  columns.
37            -x, --delete-empty-rows
38                                  After cutting, delete rows which are completely empty.
39
40       See also: ../common_arguments.
41
42       NOTE:
43          csvcut does not implement row filtering, for this  you  should  pipe
44          data to csvgrep.
45

EXAMPLES

47       Print the indices and names of all columns:
48
49          csvcut -n examples/realdata/FY09_EDU_Recipients_by_State.csv
50            1: State Name
51            2: State Abbreviate
52            3: Code
53            4: Montgomery GI Bill-Active Duty
54            5: Montgomery GI Bill- Selective Reserve
55            6: Dependents' Educational Assistance
56            7: Reserve Educational Assistance Program
57            8: Post-Vietnam Era Veteran's Educational Assistance Program
58            9: TOTAL
59           10:
60
61       Print  only  the names of all columns, by removing the indices with the
62       cut command:
63
64          csvcut -n examples/realdata/FY09_EDU_Recipients_by_State.csv | cut -c6-
65          State Name
66          State Abbreviate
67          Code
68          Montgomery GI Bill-Active Duty
69          Montgomery GI Bill- Selective Reserve
70          Dependents' Educational Assistance
71          Reserve Educational Assistance Program
72          Post-Vietnam Era Veteran's Educational Assistance Program
73          TOTAL
74
75       Extract the first and third columns:
76
77          csvcut -c 1,3 examples/realdata/FY09_EDU_Recipients_by_State.csv
78
79       Extract columns named “TOTAL” and “State Name” (in that order):
80
81          csvcut -c TOTAL,"State Name" examples/realdata/FY09_EDU_Recipients_by_State.csv
82
83       Add line numbers to a file, making no other changes:
84
85          csvcut -l examples/realdata/FY09_EDU_Recipients_by_State.csv
86
87       Extract a column that may not exist in all files:
88
89          echo d, | csvjoin examples/dummy.csv - | csvcut -c d
90          echo d, | csvjoin examples/join_no_header_row.csv - | csvcut -c d
91
92       Display a column’s unique values:
93
94          csvcut -c 1 examples/realdata/FY09_EDU_Recipients_by_State.csv | sed 1d | sort | uniq
95

AUTHOR

97       Christopher Groskopf
98
100       2016, Christopher Groskopf
101
102
103
104
1051.0.3                            Feb 02, 2019                        CSVCUT(1)
Impressum