How to open .csv files?

How do you combine multiple .csv files into a single file using the command line?

  • I'd rather not copy and paste. All the files share a common structure.

  • Answer:

    Windows: type file1.csv file2.csv > outputfile.csv Linux, MacOS cat file1.csv file2.csv > outputfile.csv Both extend to more than two input files... Update: January 2015. If the files each have headers on the first line, then you need to strip out the header from the second one before combining. Linux sed 1d file2.csv > file2noheader.csv cat file1.csv file2noheader.csv > outputfile.csv

Mark Harrison at Quora Visit the source

Was this solution helpful to you?

Other answers

for to do this in a loop take this: for i in echoâ‹….csvechoâ‹….csvecho *.csv; do     cat $i >>  output.csv done output.csv must be empty or not existing. If it exists it gets count by the 'echo *.csv' Regards, Uli

Ulrich Lorenz Schlüter

Go to the command prompt, you can do this by finding the CMD program or in the run bar on windows typing CMD.Edit: if you are using W10 type CMD into Cortana.CD into the directory that the *.csv files are in.type: copy *.csv combined.csvThis will concatenate all the csv files into one.

James Fehr

If your csv doesn't have header, you can straight away redirect the output to a new file. cat file1.csv file2.csv > file2.csv Otherwise, just trim the header line in the all the other files except the file1.

Ankush Chauhan

you can also use cat *.csv > newfile.csv

Haresh Kumar

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.