0.0
No commit activity in last 3 years
No release in over 3 years
Create instances of ORM (like ActiveRecord or Mongoid, anything that supports Model.new(attributes_as_hash)) objects from CSV
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

= 2.5.0
 Project Readme

ORM From CSV¶ ↑

github.com/ordinaryzelig/orm_from_csv

A super simple way (137 characters of code) of instantiating ORM objects from a CSV file. Supports any Ruby class that accepts a hash of attributes like ActiveRecord:

class ActiveRecord::Base
  def initialize(attributes = {})
  # ...

For ActiveRecord-specific usage, see the active_record_csv gem link below.

Usage¶ ↑

The following would read in a CSV file and return instantiated objects with attributes from the file:

SomeModel.from_csv(csv_file)

Note that it does not save the objects since that is dependent on what ORM you use.

Rails/ActiveRecord:¶ ↑

ActiveRecord::Base.extend ORMFromCSV

Other ORMs¶ ↑

Haven’t tested with any others. It shouldn’t be difficult to integrate with others. The only assumption made is that YourModel.new() should accept a hash of attributes and assign them. See spec/support/models/movie.rb for an example.

Related gems¶ ↑