lib/loaders/csv_loader.rb in datashift-0.4.3 vs lib/loaders/csv_loader.rb in datashift-0.5.0

- old
+ new

@@ -14,10 +14,13 @@ module CsvLoading include DataShift::Logging + # Options : + # strict : Raise exception if any column cannot be mapped + def perform_csv_load(file_name, options = {}) require "csv" # TODO - can we abstract out what a 'parsed file' is - so a common object can represent excel,csv etc @@ -30,10 +33,10 @@ # Create a method_mapper which maps list of headers into suitable calls on the Active Record class # For example if model has an attribute 'price' will map columns called Price, price, PRICE etc to this attribute map_headers_to_operators( @parsed_file.shift, options[:strict] , @mandatory ) unless(@method_mapper.missing_methods.empty?) - puts "WARNING: Following column headings could not be mapped : #{@method_mapper.missing_methods.inspect}" + logger.error("Following column headings could not be mapped :\n#{@method_mapper.missing_methods.inspect}") raise MappingDefinitionError, "ERROR: Missing mappings for #{@method_mapper.missing_methods.size} column headings" end #if(options[:verbose]) puts "\n\n\nLoading from CSV file: #{file_name}" \ No newline at end of file