Suppose you have one CSV file with 2 fields: ID and email. You have another file with 2 fields: email and name. How can you produce a file with all three fields joined on email?
|
|
Revision3: You must sort both lists on email alphabetically, then join. Given that the email field the 2nd field of file1 and the 1st field of file2:
parameter meaning -t , : ',' is the field separator -k 2,2 : character sort on 2nd field -k 1,1 : character sort on 1st field -1 2 : file 1, 2nd field -2 1 : file 2, 1st field > : output to file produces email,ID,name email,ID,name ... sorted by email alphabetically. Note that if any email is missing from either file it will be omitted from the results. |
||||
|
|
|
Perhaps it is overkill, but you could import into a database (e.g. OpenOffice Base) as two kinds of tables and define a report that is the desired output. If the CSV import is a problem, then a spreadsheet program (e.g. OpenOffice Calc) can do the import. The result can then easily be transferred to the database. |
||||
|
|
|
As a future reference you might want to start playing around with AWK. It's a very simple little scripting language that exists in some form on every *nix system and its sole mission is life is the manipulation of standard delimited textual databases. With a few lines of throwaway script you can do some very useful things. The language is small and elegant and has a better utility/complexity ratio than anything else I am aware of. |
|||||
|
|
The easiest resolution of the problem - make xlsx from csv and use Vlookup to search for the name in second file :) |
|||||
|