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

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

License

Notifications You must be signed in to change notification settings

continuum/active_importer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActiveImporter

![Gitter](https://badges.gitter.im/Join Chat.svg)

ARCHIVED

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

Installation

Add this line to your application's Gemfile:

gem 'active_importer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_importer

Usage

Define classes that you instruct on how to import data into data models.

class EmployeeImporter < ActiveImporter::Base
  imports Employee

  column 'First name', :first_name
  column 'Last name', :last_name
  column 'Department', :department do |department_name|
    Department.find_by(name: department_name)
  end
end

The importer defines what data model it imports data into, and how columns in the data source map to fields in the model. Also, by providing a block, the source value can be processed before being stored, as shown with the 'Department' column in the example above.

Once defined, importers can be invoked to import a given data file.

EmployeeImporter.import('/path/to/file.xls')

The data file is expected to contain columns with titles corresponding to the columns declared. Any extra columns are ignored. Any errors while processing the data file does not interrupt the whole process. Instead, errors are notified via some callbacks defined in the importer (see below).

Documentation

For mote detailed information about the different aspects of importing data with active_importer, refer to the following sections in the wiki.

Getting started

Diving in

Advanced features

Contributing

Contributions are welcome! Take a look at our contributions guide for details.