Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

joining csv's with common ids

Status
Not open for further replies.

mreider

Programmer
Nov 30, 2007
1
Hi there.

I have never used AWK, but I'm always ready to pick up a new language, and it might be the right one for the job here.

If you could give me some pointers, that would be awesome.

I have 6 CSV files.

They all have different info, but share one column in common - the "ID" column. They all have 2000 IDs, and the IDs are the same in each file.

I would like to merge all of this info, into one new CSV. The new CSV will still have 2000 IDs, but it will have all of the columns from each of the individual CSVs that were merged.

So something like...

loop through csv file 1.
Get all 2000 IDs and their data
loop through csv file 2
for each of the 2000 IDs, add columnar data with that from csv 1

Etc...

Help?
 
The join utility only joins 2 files in one go, so you'd need 5 subsequent joins (binary or sequential grouping, makes no difference for 6 files)

So I'd go for awk solution with an array which is loaded with first file, then second file appended per record with key value lookup into array, then third and so on...


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top