![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| merging of 2 files AWK, SHELL or something else | klut | Shell Programming and Scripting | 24 | 03-20-2009 09:45 AM |
| Need help passing variables in shell script to perl one-liner | Xek | Shell Programming and Scripting | 1 | 01-15-2008 03:12 PM |
| Need help for 2 data file merging | getdpg | Shell Programming and Scripting | 2 | 07-12-2006 10:07 AM |
| can i tar and gzip in one liner ? | umen | UNIX for Dummies Questions & Answers | 1 | 11-10-2005 05:11 AM |
| Merging data | ReV | Shell Programming and Scripting | 8 | 06-03-2005 04:14 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
merging CSV data using a one liner from shell?
I'm trying to merge multiple CSV (comma separated value) files into one large master file. All files have a field that is unique to act as the key for entry/merging into the master file & and all files have the same number of fields that are in the master file.
I'll give an example here: MASTERFILE (BEFORE MERGE): "userid","logon","name","fname","lname","app1","app2","app3","app4","app5" "111","","Joe One","","","yes","no","","no","" "333","","","","","","","","","" "555","","","Five","","","","","","" "222","mrtwo","Lou Two","Lou","","no","no","no","no","yes" MERGEFILE1: "111","mrone","","Joe","One","","","yes","","no" "222","","Lou Two","Lou","","no","no","no","no","yes" "555","mrfive","","","","","","","","" I imagine it would be something like: Run the script... # {somescript} masterfile mergefile1 > masterfile2 So now MASTERFILE2 would become: "111","mrone","Joe One","Joe","One","yes","no","yes","no","no" "222","mrtwo","Lou Two","Lou","","no","no","no","no","yes" "333","","","","","","","","","" "555","mrfive","","Five","","","","","","" So the first field would be be scanned from the first line of the mergefile to see if it is in the the first filed of any lines in the masterfile, if it exists in the masterfile, then it would update the fields for that entry accordingly (overwriting any existing fields in masterfile) and continue on to process the next line of the mergefile against the masterfile. How could I accomplish this? ![]() Thanks! |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|