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 split a csv file with csvkit?
- How to remove duplicates with csvkit?
- How to remove columns with csvkit?
- How to sort a csv file with csvkit?
- How to use csvkit on Windows?
- How to merge columns with csvkit?
- How to extract a column from a CSV file using csvkit?
- How to convert JSON to CSV using csvkit?
- How to convert a csv file to json with csvkit?
- How to change the encoding in csvkit?
See more codes...