app/models/bulkrax/csv_entry.rb in bulkrax-6.0.1 vs app/models/bulkrax/csv_entry.rb in bulkrax-7.0.0
- old
+ new
@@ -14,14 +14,15 @@
end
class_attribute(:csv_read_data_options, default: {})
# there's a risk that this reads the whole file into memory and could cause a memory leak
+ # we strip any special characters out of the headers. looking at you Excel
def self.read_data(path)
raise StandardError, 'CSV path empty' if path.blank?
options = {
headers: true,
- header_converters: ->(h) { h.to_s.strip.to_sym },
+ header_converters: ->(h) { h.to_s.gsub(/[^\w\d\. -]+/, '').strip.to_sym },
encoding: 'utf-8'
}.merge(csv_read_data_options)
results = CSV.read(path, **options)
csv_wrapper_class.new(results)