continuum / active_importer

Define importers that load tabular data from spreadsheets or CSV files into any ActiveRecord-like ORM.

Home Page:http://continuum.github.io/active_importer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Returning a summary message

weavermedia opened this issue · comments

During the import process I'm using the row_* callbacks to build a summary message for the user, something like:

156 row(s) processed.
154 row(s) successfully imported.
Error on row 25 - Validation failed: Email address has already been taken.
Error on row 89 - Validation failed: Email address has already been taken.

Is there any method implemented for passing this back to the caller of the importer class?

I tried result = UserImporter.import('/path/to/file.xls') to see what I got back but it was just a Range.

I'll look into it.

This references #18.

What I'd really like is some consistency with what is returned.

Depending on how the import process goes, by default, the result of the .import call can be:

  • it returns a range (if the whole process is a success)
  • it returns an exception (if there is something like a UTF-8 read-error)
  • it throws an app-wide fatal exception (if the column headers are incorrect)

It might be good to get something useful and consistent returned back from the method call.