debugg csv_import

This commit is contained in:
PEB 2022-05-25 18:37:38 +02:00
parent 06ed744c58
commit cf55be7cfc

View File

@ -68,31 +68,31 @@ class ImportCsv < ApplicationRecord
end
csv_text = File.read(self.file.path, :encoding => 'UTF-8')
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ",")
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
r = []
@csv.each do |row|
line = {}
self.import_csv_champs.each do |import_csv_champ|
if import_csv_champ.header?
eval "line['#{import_csv_champ.champ}'] = row[\"#{import_csv_champ.header}\"]"
elsif import_csv_champ.value?
eval "line['#{import_csv_champ.champ}'] = \"#{import_csv_champ.value}\""
eval "line['#{import_csv_champ.champ}'] = #{import_csv_champ.value}"
end
end
r << line
end
return r
end
def load
self.table_name.classify.constantize.import_csv(self.charge, self, self.m_odr_id)
end