fastercsv parsing to int or other into ActiveRecord

Posted by Schroedinger on Stack Overflow See other posts from Stack Overflow or by Schroedinger
Published on 2010-04-19T07:18:18Z Indexed on 2010/04/19 7:23 UTC
Read the original article Hit count: 398

Filed under:
|
|
|
|

I'm currently importing a CSV into an activerecord element but can't choose to parse the elements as say ints or decimals on a case by case basis using fastercsv. I can either choose to parse everything as an int or the other, or all as strings. I need to parse some columns as ints, some as decimals and some as strings.

Otherwise, is there a way after I've parsed everything as strings to convert and update individual elements in the activerecord to the new form? Say parse values in as strings then convert certain values to ints, others to decs, etc?

© Stack Overflow or respective owner

Related posts about rails

Related posts about fastercsv