On Oct 22, 2012, at 11:33 PM, Todd S. [email protected] wrote:
I have 8 csv dumps that I receive nightly. I have to transform them
into XML and FTP them. So far I have been able to complete this task.
Now the requirements are to match some records up between csv dumps.
I did not want to load all the files into a database, as I only work
with each nights data. I thought I could convert the csv to a model
after parsing it. I am unable to find information on converting the CSV
to active record or an active-model (not sure either one of these ideas
are correct approach).
ActiveRecord requires a database. Persisting data in an SQL-database is
the whole point of the library.
ActiveModel is an interface that generalises common tasks with
It works by giving you a general implementation in which you have to
fill out the
blanks. ActiveRecord one of such implementations. Writing a
AM-implementation for a bit of CSV data might be a bit too much.
There are multiple approaches:
- Just use plain old ruby objects and than match them by arranging the
objects in memory. Its a bit more legwork, but depending on your dataset
size, it shouldn’t
be too difficult.
- If the task is more complex, why not connect ActiveRecord, DataMapper
or Sequel to an
in-memory-SQLite database (“sqlite://:memory:”, afaik)? This gives you
all the power of the
corresponding lib, but without the headache of handling a DB server.
I hope this gives you a few pointers. Without knowing the actual tasks
and the size of those
files, its hard to make good suggestions.