How can I combine multiple csv files with different number of records?

N

nicolai

I have a number of csv files that I would like to combine into one
spreadsheets. The problem is that not all the data is consistent. Here
is an example of what they look like:

File1:
Country Population
Armenia 100
Bangladesh 220
Cuba 103
Denmark 98

File2:
Country GDP
Armenia 12
Bangladesh 33
Denmark 48

etc, etc for about 300 countries

As you will notice, File 2 has no data for Cuba. I want to combine all
the data into one spreadsheet. If all countries were represented in
every file I would simply copy and paste the entire column, but that
wont work as the columns are never the same length.

by combining file 1 and 2 I would like to get the following

Country Population GDP
Armenia 100 12
Bangladesh 220 33
Cuba 103
Denmark 98 48




Any ideas on a quick clever way to do this?
 
S

smw226 via OfficeKB.com

Hi,

When I need to combine many csv files i use binary copy.

open a new command promt. then its :-
copy \b "full path to the folder containing"/*.csv "full path where you want
the file saved to"/joined.csv

this will join all the files into 1.

then, presuming you have less rows than Excel can handle! pivot (if all the
values are numeric) or I would put the data into Access and cross-tab it if
you have text in there too.

HTH

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top