csvkitHow to remove columns with csvkit?
csvkit is a suite of command-line tools for working with CSV, the most popular being csvcut
. csvcut
can be used to remove columns from a CSV file.
Example code
csvcut -c 1,3,4 input.csv > output.csv
This command will remove the second column from the input file and save the result to output.csv.
Code explanation
csvcut
: the command used to remove columns from a CSV file-c
: the flag used to specify which columns to keep1,3,4
: the columns to keep, in this case columns 1, 3, and 4input.csv
: the input file>
: the redirection operator used to save the output to a fileoutput.csv
: the output file
Helpful links
More of Csvkit
- How to skip the first line with csvkit?
- How to select specific columns with csvkit?
- How to fetch unique values with csvkit?
- How to merge columns with csvkit?
- How to convert a tsv file to csv with csvkit?
- How to change the encoding in csvkit?
- How to split a csv file with csvkit?
- How to remove duplicates with csvkit?
- How to convert a csv file to tab delimited with csvkit?
- How to sort a csv file with csvkit?
See more codes...