On 11/4/2010 12:20 PM, Bob West wrote: > I'm a complete noob to ruby and am hoping someone can help me with this. > > I have a csv file with one field called geo_enabled (the 6th column). > The values are true or false. If the value is true, I'd like to return > the values contained in the field called Geo (7th column). If it is > false, I'd like to return the values in the "Location" field (8th > column). > > I've got a rough idea how this should go. But it isn't close to being > working code. > > I'd really appreciate all help anyone can provide. require 'csv' CSV.open('your-file.csv', 'r') do |row| puts(row[5] == 'true' ? row[6] : row[7]) end This uses the csv module to parse the file and iterate row by row through the data. It checks if the 6th column is 'true' and prints the 7th column if so or the 8th column otherwise. This code should be made more robust by at least checking for invalid data in the 6th column rather than assuming that any value other than 'true' is the same as 'false'. -Jeremy