Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/continuum/active_importer
Define importers that load tabular data from spreadsheets or CSV files into any ActiveRecord-like ORM.
https://github.com/continuum/active_importer
activerecord csv-files data-import importer orm ruby spreadsheet tabular-data
Last synced: 2 months ago
JSON representation
Define importers that load tabular data from spreadsheets or CSV files into any ActiveRecord-like ORM.
- Host: GitHub
- URL: https://github.com/continuum/active_importer
- Owner: continuum
- License: mit
- Archived: true
- Created: 2013-11-05T17:13:47.000Z (about 11 years ago)
- Default Branch: develop
- Last Pushed: 2021-11-23T12:48:58.000Z (about 3 years ago)
- Last Synced: 2024-10-02T07:28:22.577Z (3 months ago)
- Topics: activerecord, csv-files, data-import, importer, orm, ruby, spreadsheet, tabular-data
- Language: Ruby
- Homepage: http://continuum.github.io/active_importer/
- Size: 160 KB
- Stars: 330
- Watchers: 47
- Forks: 19
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-ruby - ActiveImporter - Define importers that load tabular data from spreadsheets or CSV files into any ActiveRecord-like ORM. (ORM/ODM Extensions)
README
# ActiveImporter
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/continuum/active_importer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)## 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.
```ruby
class EmployeeImporter < ActiveImporter::Base
imports Employeecolumn '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.
```ruby
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](https://github.com/continuum/active_importer/wiki).### Getting started
* [Understanding how spreadsheets are parsed](https://github.com/continuum/active_importer/wiki/Understanding-how-spreadsheets-are-parsed)
* [Mapping columns to attributes](https://github.com/continuum/active_importer/wiki/Mapping-columns-to-attributes)### Diving in
* [Custom data processing](https://github.com/continuum/active_importer/wiki/Custom-data-processing)
* [Helper methods](https://github.com/continuum/active_importer/wiki/Helper-methods)
* [File extension and supported formats](https://github.com/continuum/active_importer/wiki/File-extension-and-supported-formats)
* [Passing custom parameters](https://github.com/continuum/active_importer/wiki/Custom-parameters)
* [Events and callbacks](https://github.com/continuum/active_importer/wiki/Callbacks)
* [Selecting the model instance to import into (Update instead of create)](https://github.com/continuum/active_importer/wiki/Update-instead-of-create)
* [Error handling](https://github.com/continuum/active_importer/wiki/Error-handling)
* [Selecting the sheet to get data from](https://github.com/continuum/active_importer/wiki/Selecting-the-sheet-to-work-with)
* [Skipping rows](https://github.com/continuum/active_importer/wiki/Skipping-rows)### Advanced features
* [Aborting the import process](https://github.com/continuum/active_importer/wiki/Aborting-the-import-process)
* [Transactional importers](https://github.com/continuum/active_importer/wiki/Transactional-importers)## Contributing
Contributions are welcome! Take a look at our [contributions guide][] for
details.[contributions guide]: https://github.com/continuum/active_importer/wiki/Contributing