I have a CSV and using the default CSV library would like to apply different converters to different columns
headers are:
units_at_warehouse(#integer),
external_id(#string),
released(#date),
list_price_cents(#integer)
I am current using these options:
options = {
headers: true,
converters: nil,
header_converters: :symbol
}
CSV.foreach(file, options) do |row|
# current my best option is:
convert_integers(row)
convert_dates(row)
persist(row)#...saving
end
Is it possible to pass in a converter PER column?
Something like:
options = {
headers: true,
header_converters: :symbol,
converters: {
units_at_warehouse: :numeric,
list_price_cents: :numeric,
released: :date
}
}