CSV file merge help
Hi,
Although I'm not a developer, I can pick things up when spoon fed a little :-) Here is what I'm trying to accomplish (a friend suggested BASH for this).... I have two CSV files, a demographics file and a financial file and I wish to merge them using a unique ID. Demographics.csv ID, surname, first name, address 1, address 2, address 3, address 4 8761, Jones, John, 10 Street, London, , NW1 4TT 36609, Smith, Ken, 10 Road, London, , NW1 6JJ 89877, Miller, Luke, 70 Something, Harlow, Essex, ES6 8JU 8786, Riley, Kim, 67 Runway, Grantham, , GR5 7FD 5432, Kendal, Clive, 89 Street, London, NW1 4TT Finance.csv ID, Balance 8761, 300.00 36609, -200.00 89877, 500.00 The third file which is my desired output would look like this:- output.csv ID, surname, first name, address 1, address 2, address 3, address 4, balance 8761, Jones, John, 10 Street, London, , NW1 4TT, 300.00 36609, Smith, Ken, 10 Road, London, , NW1 6JJ, -200.00 89877, Miller, Luke, 70 Something, Harlow, Essex, ES6 8JU, 500.00 Where no ID is found in finance.csv, do not write output in the output.csv How would I ideally accomplish this? Code samples would be great if possible. Many thanks for your help. |
The join command is what you're looking for:
join demographics.csv finance.csv will provide you with the desired output. It has many options, anyway the example above should be ok for you |
Thank you clvic.
I used the following to generate what I needed:- [HTML]join '/home/lmedland/Desktop/demo.csv' '/home/lmedland/Desktop/fin.csv' -t , > output.csv[/HTML] |
All times are GMT -5. The time now is 07:19 PM. |