What is a clever way to remove rows from a CSV file in ruby where a particular value exists in a particular row?
Here\'s an example of a file:
350 lbs.,
Well, I don't think this example will get the answer you are looking for... but this would work...
tmp.txt =>
350 lbs., Outrigger Footprint, 61" x 53", Weight, 767 lbs., 300-2080
350 lbs., Outrigger Footprint, 61" x 53", Weight, 817 lbs., 300-2580
350 lbs., Outrigger Footprint, 61" x 53", Weight, 817 lbs., 300-2580
350 lbs., Outrigger Footprint, 69" x 61", Weight, 867 lbs., 300-3080
350 lbs., Outrigger Footprint, 69" x 61", Weight, 867 lbs., 300-3080
File.readlines('tmp.txt').uniq
will return this:
350 lbs., Outrigger Footprint, 61" x 53", Weight, 767 lbs., 300-2080
350 lbs., Outrigger Footprint, 61" x 53", Weight, 817 lbs., 300-2580
350 lbs., Outrigger Footprint, 69" x 61", Weight, 867 lbs., 300-3080
So, you could also easily sort with Array fxns. Google ruby arrays and I'm sure you can learn how to choose if you want an entry according to a comparison to a desired string.