Open joel opened 5 years ago
Plus + You can create general behaviour here:
require 'csv_importer'
module CSVImporter
def self.sanitize_cell(raw_value)
if %(y yes t true 1).inlcude?(raw_value)
'YES'
else
raw_value
end
end
end
@pcreux sure, some source of inspiration https://github.com/s12chung/csv_row_model#attribute-values ;-)
Custom cell sanitising
By default cell values are stripped, that means " Bob Elvis " become "Bob Elvis", however you may want to go further and get rid of the inner extra spaces that often present on cell value and get the proper "Bob Elvis" To do that, add an initialiser
config/initializers/csv_importer.rb
and define you proper rules.