This nifty tool converts your csv into a ActiveRecord model and sqlite database, and then lets you use activerecord/arel/ other awesome ruby gems to query it.
csv-active or c-s-vactive
(because that’s super important)
It’s a ruby script to help you process data. It:
I’ve noticed that people use excel for lots of things. And guru excel users think v-lookup is crack. When in reality one of the simplest database functions (a join) would be a million times more powerful in accomplishing their task. And then instead of pushing the limits, they are starting at the ground floor.
And here’s the thing about that:
Boom. V-lookup => csvactive => rails. #gatewaydrug
Sounds important now right?
You need
From a console in the csvactive directory
bundle install
ruby csvactive.rb <put csv file path here>
# like this: ruby csvactive.rb ~/Desktop/somefile.csv
things happen, then you pop into a console with a model called Thing.
let’s say your CSV had roster data. try these things:
Thing.first.first_name # find the first person's first name
Thing.where(first_name: 'John') # find all the cool people
Thing.order(:first_name) # order them by first name
Thing.pluck(:first_name) # grab an array of all the first names
Thing.pluck(:first_name).to_sql # learn!
you can also have fun with floats and dates. if your data has numbers or dates in it, the script will figure it out and convert them before saving to database
Thing.where("things.start_date >= #{3.days.ago}") # find the employees that started in the last 3 days
Thing.where("things.magic_stars >= 4") # find star performers
once you’ve mastered that, add squeel to the mix
Thing.where{start_date >= 3.days.ago}
Thing.where{(name =~ 'Ernie%') & (salary < 50000) | (name =~ 'Joe%') & (salary > 100000)}
can excel do that?
so yeah, contribute - open an issue or pull request or what not. i’m always listening. 😃
and give feedback! i’d love to hear if this helps anyone other than myself and my coauthor @polyfish42
tweet me @jmondo