csvkitHow to reorder columns with csvkit?
csvkit is a suite of command-line tools for working with CSV files. It can be used to reorder columns in a CSV file.
Example code
csvcut -c <columns> <input_file> | csvformat -T > <output_file>
Output example
column1,column2,column3
value1,value2,value3
Code explanation
csvcut
: used to select the columns to be included in the output file-c
: used to specify the columns to be included in the output file<columns>
: the list of columns to be included in the output file, separated by commas<input_file>
: the path to the input CSV filecsvformat
: used to format the output file-T
: used to output the file in tabular format<output_file>
: the path to the output CSV file
Helpful links
More of Csvkit
- How to convert a tsv file to csv with csvkit?
- How to split a csv file with csvkit?
- How to select specific columns with csvkit?
- How to remove duplicates with csvkit?
- How to convert JSON to CSV using csvkit?
- How to convert a csv file to tab delimited with csvkit?
- How to sort a csv file with csvkit?
- How to rename a column with csvkit?
- How to merge columns with csvkit?
See more codes...