9951 explained code solutions for 126 technologies


csvkitHow to merge columns with csvkit?


csvkit is a suite of command-line tools for working with CSV files. It can be used to merge columns from multiple CSV files into a single file.

Example code

csvstack -n 1,2,3 file1.csv file2.csv > merged.csv

Output example

1,2,3
a,b,c
d,e,f
g,h,i

Code explanation

  • csvstack: the command to merge columns from multiple CSV files
  • -n 1,2,3: the option to specify which columns to merge
  • file1.csv and file2.csv: the two files to be merged
  • > merged.csv: the output file

Helpful links

Edit this code on GitHub