Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Skipping rows

Ernesto García edited this page Feb 17, 2014 · 2 revisions

Sometimes a spreadsheet may contain some rows in between the data rows, that are not meant to be imported. The most common example are rows with subtotals, but there may be other situations alike. For these cases, it's useful to be able to tell the importer to skip those unwanted rows, without signaling an error condition, and without counting that row as processed.

This can be achieved by giving the importer a condition identifying rows to be skipped. This is better shown in the example below:

class EmployeeImporter < ActiveImporter::Base
  imports Employee

  skip_rows_if { row['Name'].blank? }

  # ...
end

The importer above will skip all rows for which the value if the 'Name' column is blank.