ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How can I combine multiple csv files with different number of records? (https://www.excelbanter.com/excel-discussion-misc-queries/165352-how-can-i-combine-multiple-csv-files-different-number-records.html)

[email protected]

How can I combine multiple csv files with different number of records?
 
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?


smw226 via OfficeKB.com

How can I combine multiple csv files with different number of records?
 
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


wrote:
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?


--
--------------------
Simon - UK

Email at simon22mports [ a t ] hot mail [ d ot ]com

Message posted via
http://www.officekb.com



All times are GMT +1. The time now is 10:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com