Subscribe to this feed

Navigation

Recent Posts

Archive

Merge Multiple CSV Files

Sunday 01 Apr, 2007 - 14:48pm | 54 comments |

You can merge multiple csv or text files with a simple DOS command. Copy the code below into a text editor and save the file with a .bat extension. Save the file in the same folder as the csv files.

copy *.csv importfile.csv

I've used this as part of an import routine. Step one produces a set of csv files from SQL queries on an Oracle database. Step two merges all the csv files together. Step three imports a single file into Sage MMS

Posted in: Business
Tags: csv | File Import | batch files | bat

Comment
 | Link | back to top | del.icio.us digg it furl reddit

.. Exellent

Tuesday 25 Mar, 2014 - 14:56pm
Merci beaucoup pour cette astuce !

Posted by: Anonymous

.. Thank you!!

Wednesday 27 Nov, 2013 - 22:21pm
Easy and to the point. This is by far the best! Thank you!!

Posted by: Anonymous

..

Sunday 29 Sep, 2013 - 10:53am
Thank you.  You made my day.  Save me hours and put a big smile on my face. 

Posted by: Anonymous

.. ...

Wednesday 18 Sep, 2013 - 11:20am
big thanks

Posted by: Anonymous

.. Brilliant!

Thursday 18 Jul, 2013 - 17:49pm
easy and instant result thanks.

Posted by: Anonymous

..

Wednesday 08 May, 2013 - 11:40am
wonder full...............

Posted by: Anonymous

..

Friday 22 Mar, 2013 - 10:17am
simply genius...!!!

Posted by: Anonymous

.. Another thank you

Friday 15 Mar, 2013 - 00:59am
wow like someone else said... 2 seconds great, thanks very much.

Posted by: Anonymous

.. Fantastic

Saturday 19 Jan, 2013 - 12:26pm
cat *.csv > new file.csv so fast so good thanks

Posted by: Anonymous

..

Thursday 29 Nov, 2012 - 20:35pm
Wow!!  I've been days going through VBA code to do this exact thing. I have dozens of CSV files with thousands of items in each to combine.  Thank you so much!!

Posted by: Anonymous

.. U saved me !!

Tuesday 30 Oct, 2012 - 18:11pm
I had a friend write macro to do this stuff and it was taking hours cos of huge csv files and with this command it took 2 seconds !! . Awesome and Thanks a Ton - Pankaj

Posted by: Anonymous

.. For MAC OSX or Linux

Thursday 04 Oct, 2012 - 03:19am
Use cat instead of copy and send it to a new file. This works: cat *.csv > newfile.csv

Posted by: Anonymous

.. THANKS

Tuesday 21 Aug, 2012 - 08:45am
My God you saved my hours of boring repetitive work. Thanks!!!

Posted by: Anonymous

.. Simply Brilliant

Thursday 02 Aug, 2012 - 05:09am
After searching for vba macros to do this for me I found this incredibly simple trick. You are AWESOME!!!

Posted by: Anonymous

..

Wednesday 20 Jun, 2012 - 23:10pm
Hi thx for the share, but I can't seem to get the .txt. file to convert to .bat in windows 7. the extension says .bat, but it hasn't changed, thus doesn't work. Any suggestions?

Posted by: Anonymous

.. THANK YOU!

Friday 15 Jun, 2012 - 00:24am
You saved me HOURS of copy & paste. Thx soooo much!

Posted by: Anonymous

.. Many thanks

Tuesday 12 Jun, 2012 - 04:07am
Great Idea!!! I will use this every month to consolidate daily files into one monthly. Thought I was going to have to spend an hour of not fun work each month and your command combines them all into a single file in 15 seconds!!!

Posted by: Anonymous

.. This worked great for me

Monday 14 May, 2012 - 07:37am
Thank you so much for this batch file, it saved me heaps of work. I need to import into MySQL via CSV files, and I had around 5000 files that I started to splice via Excel; probably I would need a week to do so otherwise. Headers are a concern, the way I handled it was to open the spliced file in Excel, then apply a filter that makes all the header rows show. Then simply mark all rows and select "delete row" from the context menu. It will only delete the header rows and keep the data rows intact. Cheers!

Posted by: Anonymous

.. eliminating duplicate headers

Thursday 19 Apr, 2012 - 16:51pm
great post! my csv files each have a header row and when i concatenate them, the header row gets duplicated between the end of the previous file and the start of the next one. i then can't import the entire csv in something like postgresql. any suggestion how i can import just the contents sans the headers? thanks in advance.

Posted by: Anonymous

.. Still awesome

Wednesday 14 Mar, 2012 - 16:08pm
After all these years....

Posted by: Anonymous

.. can this work on a mac?

Friday 24 Feb, 2012 - 17:55pm

Posted by: Anonymous

.. Thanks!

Tuesday 07 Feb, 2012 - 05:41am

Phew at last found it ,a simple way to do this..thanks a lot for posting it, appreciate it .I was looking high and low for simple codes to read mulitple csv into one. Glad found ur site :)

Posted by: Anonymous

.. Thank you!

Wednesday 01 Feb, 2012 - 20:54pm
Echoing some other grateful people. THANKS SO MUCH!

Posted by: Anonymous

.. You are the champion

Saturday 28 Jan, 2012 - 23:46pm
You just save me about $70 bucks that I was going to dish out on Batch File Manager. THANK YOU THANK THANK YOU Zorba the CHAMPION!

Posted by: Anonymous

.. Great

Wednesday 18 Jan, 2012 - 18:38pm
Great Idea. Thanks!

Posted by: Anonymous

.. GREAT

Monday 16 Jan, 2012 - 18:55pm
GREAT SHORT CUT AND WORKED IN LESS THAN ONE SECOND FOR 10 FILES! THANK YOU MAN.

Posted by: Anonymous

.. Paul

Friday 06 Jan, 2012 - 11:41am
Thanks a lot...worked good.

Posted by: Anonymous

.. Paul

Friday 06 Jan, 2012 - 11:41am
Thanks a lot...worked good.

Posted by: Anonymous

.. Thanks!

Wednesday 28 Dec, 2011 - 17:15pm

Posted by: Anonymous

.. ZORBA ROCKS

Tuesday 20 Dec, 2011 - 22:05pm
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Posted by: Anonymous

.. AWESOME

Thursday 17 Nov, 2011 - 17:03pm

I never make comments on website but this is worthy of a HUGE HUG and THANK YOU!  You saved me TONS of time on an already tight deadline!  THANK YOU!

Posted by: Anonymous

.. very nice

Wednesday 16 Nov, 2011 - 03:10am
huge timesaver. Thank you!

Posted by: Anonymous

.. brilliant!

Tuesday 20 Sep, 2011 - 11:05am
thanks for this great idea! what a simple and effective one, using DOS command... would have never thought of that :) works perfectly for merging multiple csv files into a single file (had to process ~1000 files and didn't really favor doing it in copy paste mode :)

Posted by: Anonymous

.. Thank you so very much for this.

Tuesday 21 Jun, 2011 - 20:06pm
Even in office 2010 this is still a PITA. This worked flawlessly.

Posted by: Anonymous

.. Mac/Linux

Monday 20 Jun, 2011 - 16:37pm
The more correct way to do this on a *nix system is with 'cat *.csv > output.csv'

Posted by: Anonymous

.. Mac copy

Sunday 01 May, 2011 - 13:30pm
just use CP or MV on mac. e.g on mac (or linux): cp *.csv importing.csv mv *.csv importing.csv

Posted by: Anonymous

.. Saved me time & headache

Sunday 03 Apr, 2011 - 07:10am
I was surprised that I couldn't simply import multiple .csv files into Microsoft Excel and just have it append into the worksheet. I needed to combine about 36 monthly bank statements from online banking into one .csv file. You saved me a lot of time and frustration, thanks for sharing your knowledge.

Posted by: Anonymous

.. thanks

Sunday 06 Mar, 2011 - 15:38pm
thanks...really useful...

Posted by: Anonymous

.. Holly molly!

Sunday 27 Feb, 2011 - 06:11am
You da best man!!!! Thanks a million. Mike

Posted by: Anonymous

.. Saved me soooooo much time

Thursday 07 Oct, 2010 - 21:07pm
Works so well and is a simple as it sounds!  You saved me at least 10 hours or labourious, erro prone work.  THANKS!!!

Posted by: Anonymous

..

Friday 24 Sep, 2010 - 11:00am
Incredibly useful little little one, thank you!

Posted by: Anonymous

.. merge two versions

Friday 11 Jun, 2010 - 20:57pm
You can also do an intelligent merge of changes in two csv files edited by different people using ssmerge, see http://coopy.sourceforge.net

Posted by: Anonymous

.. Mac

Friday 09 Apr, 2010 - 16:32pm
Hey! Does this work for Mac's? I'm not sure do macs use dos? If not, is there any way to do it with a Mac?

Posted by: Anonymous

.. Awesome

Wednesday 02 Dec, 2009 - 16:14pm
Thanks so much, I just merged 78 csv files that I was about to do by hand. You might want to consider adding a paypal donate button on the bottom your awesome posts! Hint, Hint :)

Posted by: Anonymous

.. Thank you!

Tuesday 11 Aug, 2009 - 11:01am
Hi Zorba, What a brilliant utility - you saved me hours of time :) One thing I couldnt fix was this: I have 100 or so csvs, the header rows are not text qualified, but all the data within the csvs are text qualified. when I merge the csvs, obviously the headers get merged too and that kindof deletes some important cells and pushes the data into the wring column, Is there a way ti ignire the header or a script which will remove the header before merging? Any help gratefully appreciated regards Kash kash (a t ) noorfoundation ( d o t ) org

Posted by: Anonymous

.. merging txt files

Saturday 13 Jun, 2009 - 08:05am

hi zorba,

 

i want to merge a set of 100 txt files daily to their respective existing files (not all files into one super file). can u kindly help??

thanks

regards

algae

algaeginger@gmail.com

 

 

Posted by: Anonymous

.. merge csv files

Friday 13 Mar, 2009 - 10:44am
This is nice to be able to merge your csv files into one file, but I have a situation weherby I receive my invoices on a cd-rom that contains 2 types of csv files that need to be split over 2 different merged csv files. On the cd-rom i have invoices that end with the characters VAR and FIX, so basically I need to merge all the files that end with VAR to InvoicesVAR.csv and all files that end with FIX to invoicesFIX.csv. Is there a dos command that can look at the last 3 characters of a csv file? This is an example of how the files look like, for example: Invoice001VAR.csv, Invoice001FIX.csv, etc... Any help is most appreciated.

Posted by: Anonymous

.. this really helped!

Thursday 20 Nov, 2008 - 21:49pm

You just saved me so much time, since I was about to start merging all of these manually. I love you. 

Posted by: Anonymous

.. Very helpful

Saturday 20 Sep, 2008 - 01:04am
Thanks this worked really well.

Posted by: Anonymous

.. Yes, if.....

Sunday 02 Dec, 2007 - 22:09pm
Hi Allan I am not sure I understand the question. The dos command will simply merge together the csv files. If the csv files are in Line 50 import format then you can import the single merge file into Sage. The command doesn't format the file in any way. You would need to do this is the queries which produce the csv files. Alternatively you could merge the files and then format them with something like PHP, if for example, you wanted to produce a single XML file for import you could use the PHP file handing functions. Best....

Posted by: ZorbaTheGeek

..

Monday 12 Nov, 2007 - 13:19pm

Is this also compatible with sage line 50?

Allan

Frustrated Software Engineer

Posted by: Anonymous

..

Monday 12 Nov, 2007 - 13:19pm

Is this also compatible with sage line 50?

Allan

Frustrated

Posted by: Anonymous

.. You rock!

Saturday 18 Aug, 2007 - 23:39pm
:)

Posted by: Anonymous

.. Fine

Monday 02 Jul, 2007 - 20:17pm
You're my hero

Posted by: Anonymous


© Eriginal Ltd 2011, all rights reserved