Project

importeroo

0.0
No commit activity in last 3 years
No release in over 3 years
Import items from a CSV into an activerecord model
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.11

Runtime

 Project Readme

importeroo

A simple gem to load ActiveRecord seeds files from a Excel Spreadsheet, OpenOffice Spreadsheet, or CSV. Coming soon: Google Drive Spreadsheets. Note: this will deletes any existing data in the seed tables before importing.

Requirements

  • Ruby 1.9

Installation

Add to gemfile:

gem 'importeroo', :git => "git@github.com:tracedwax/importeroo.git"

Usage

In db/seeds.rb:

require 'importeroo/importer'

Importeroo::Importer.new(MyActiveRecordClass, "FileType", "path/to/file").import!

For Google Docs:

Importeroo::Importer.new(MyActiveRecordClass, "Google", "KEYcodeFROMgdocsURL")

The code for the google doc is the long alphanumeric key listed in the URL. For example:

https://docs.google.com/spreadsheet/ccc?key=0AmX1I4h6m35OdFhlbDdLdnZfTUFnSVRzd0hqMjM1bUE#gid=0, the key is 0AmX1I4h6m35OdFhlbDdLdnZfTUFnSVRzd0hqMjM1bUE.

If your doc is not visible to anyone with the URL, you will also need to set the google username and password in config/importeroo.rb, or anywhere:

Importeroo.google_username = ENV["GOOGLE_USERNAME"]
Importeroo.google_password = ENV["GOOGLE_PASSWORD"]

For CSV, Excel, or OpenOffice:

Importeroo::Importer.new(MyActiveRecordClass, "CSV", "path/to/file.csv")
Importeroo::Importer.new(MyActiveRecordClass, "Excelx", "path/to/file.xlsx") # current Excel
Importeroo::Importer.new(MyActiveRecordClass, "Excel", "path/to/file.xls")   # old Excel
Importeroo::Importer.new(MyActiveRecordClass, "OpenOffice", "path/to/file.ods")

Recommended path to file:

data/import/my_active_record_class_pluralized.csv