I am trying to figure out the best way to pull a value from a CSV file called lookup.csv
based on a value in master.csv
, and then save the new file as output.csv
.
In the example below, the master file has three columns of data with the last column being City
. I'd like to replace the City
name with the City Code
from the lookup.csv
file.
I don't have a DB that I can lookup from so I am having to use the CSV file. I am trying to use FasterCSV with Ruby 1.8.7.
Example File Structure:
master.csv:
First Name | Last Name | City
Joey | Jello | Atlanta
Home | Boy | Dallas
lookup.csv:
City | City ID
Atlanta | 12345
Dallas | 12346
Houston | 12347
output.csv:
First Name | Last Name | City
Joey | Jello | 12345
Home | Boy | 12346