Skip to content

Commit

Permalink
Ensure empty spreadsheet rows are skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
payten committed Apr 12, 2023
1 parent 3adf510 commit edd2ba8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions backend/model/spreadsheet_bulk_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,6 @@ def extract_columns(filename)
def extract_ao_ids(filename)
result = []
each_row(filename) do |row|
next if row.empty?
result << Integer(row.fetch('id'))
end
result
Expand Down Expand Up @@ -1137,7 +1136,6 @@ def extract_top_containers_from_sheet(filename, top_container_columns)
top_containers = {}

each_row(filename) do |row|
next if row.empty?
by_index = {}
top_container_columns.each do |path, column|
by_index[column.index] ||= TopContainerCandidate.new
Expand All @@ -1156,7 +1154,6 @@ def extract_digital_objects_from_sheet(filename, digital_object_columns)
digital_objects = {}

each_row(filename) do |row|
next if row.empty?
by_index = {}
digital_object_columns.each do |path, column|
by_index[column.index] ||= DigitalObjectCandidate.new
Expand All @@ -1175,8 +1172,6 @@ def extract_accessions_from_sheet(db, filename, related_accession_columns)
accessions = {}

each_row(filename) do |row|
next if row.empty?

by_index = {}
related_accession_columns.each do |path, column|
by_index[column.index] ||= AccessionCandidate.new
Expand Down Expand Up @@ -1289,7 +1284,11 @@ def each_row(filename)
elsif idx == 1
headers = row_values(row)
else
yield Row.new(headers.zip(row_values(row)).to_h, idx + 1)
values = row_values(row)

next if values.all?{|v| v.nil?}

yield Row.new(headers.zip(values).to_h, idx + 1)
end
end
end
Expand Down

0 comments on commit edd2ba8

Please sign in to comment.