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 select specific columns with csvkit?
- How to merge columns with csvkit?
- How to fetch unique values with csvkit?
- How to split a csv file with csvkit?
- How to rename a column with csvkit?
- How to skip the first line with csvkit?
- How to remove duplicates with csvkit?
- How to use csvkit on Windows?
- How to convert a json file to csv with csvkit?
See more codes...