Compare two CSV files and copy field on match
$30-100 USD
Paid on delivery
I had such a great experience the first time, thought I would try it again.
I would like to have a script (PHP or Perl running from Linux Command Line) that will compare two different fields in two different CSV files, and if it finds a match, it will copy a field from the first CSV file and put it in the second CSV file.
So if I have a column (selected via script variable or command line option) with ManufacturerID's, the first row has a ABC123 as a manufacturer ID in that field, it will search through a column in the second CSV file (again selected via script variable or command line option) and if it finds a match (cannot be case sensitive, if it finds abc123, it should still match it), it will then copy data from the same row in a second column from the first CSV file to a a column in the second CSV in the matching row(both again selectable as mentioned above).
CSV 1:
"abc123","Title","Description","0123456789"
"abc456","Title","Description","1234567890"
"123efg","Title","Description","4982757482"
CSV 2:
"Title","ABC123","Description",""
"Title","abc456",""Description",""
"Title","abc789","Description",""
First run for example, take abc123 (from column 1) in CSV 1 and search in CSV 2 for it in (in column 2) for it. Since it sees ABC123, it will then take 0123456789 from Column 4 in CSV 1 and put it in Column 4 in CSV 2. Same for abc456 since there is a match. It won't do anything with 123efg as it isn't found in CSV 2. So CSV 2 after it processes should look like this:
CSV 2:
"Title","ABC123","Description","0123456789"
"Title","abc456",""Description","1234567890"
"Title","abc789","Description",""
As mentioned above, I have different CSV files that put this data in different fields, so I will need to be able to change columns either via command line or variable within the script (at the top) and also the CSV file names. The program can either be in Perl or PHP and has to run from Linux Command Line.
Project ID: #3812673