0.0
No commit activity in last 3 years
No release in over 3 years
Parse CSV spreadsheets into ActiveRecord objects
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

CSV Import Ruby

CSV Import Ruby is a gem that allows users to add an importer function into ActiveRecord models with a simple configuration.

Getting Started

To install CSV Import Ruby:

gem install csv_import_ruby

Implementation

In your ActiveRecord model:

class Student < ActiveRecord::Base
  create_importer :name, :grade, { remove_whitespace: true }
end

Arguments are symbols that represent CSV column names, with the exception of the last argument which is a hash of options. Currently, the only option is remove_whitespace, which defaults to false.

Symbols will be ignored unless they correspond to ActiveRecord attribute names.

create_importer adds two methods to Ruby objects: import! and import_file!.

Student.import!("Joe,85\nAnnie,90\nDaniel,80")
Student.import_file!("./roster.csv")

License

This project is licensed under the MIT License.