34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/cure/extract/extractor.rb', line 34
def parse_csv(file, ref_name:)
nr_processor = named_range_processor(ref_name: ref_name)
v_processor = variable_processor(ref_name: ref_name)
sample_rows = config.template..sample_rows
row_count = 0
database_service.with_transaction do
CSV.foreach(file, liberal_parsing: true) do |row|
next if sample_rows && row_count >= sample_rows
nr_processor.process_row(row_count, row)
v_processor.process_row(row_count, row)
row_count += 1
log_info "#{row_count} rows processed [#{Time.now}]" if (row_count % 1_000).zero?
end
nr_processor.after_process
end
log_info "[#{row_count}] total rows parsed from CSV"
end
|