addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Nash.rb Message Board › Ready to rethink CSV > sqlite3

Ready to rethink CSV > sqlite3

Nashville, TN
Post #: 2
As I mentioned tonight, my parameters are to use the utilities in a stock OS X machine so that a user can drag/drop a CSV file and have it populate a new instance of sqlite3 which is also on the stock machine.

Someone mentioned using Active Record which s/b doable since rails in some form is on a Leopard machine. Ideally, I'd like to do this with a bash command line.

The CSV file has the field names as the first record. The db would be dropped after I use the data as the next CSV file will have different fields, rows.

With those parameters how should I attack this problem? thanx, sam
A former member
Post #: 1
Well I didn't want to steal anyone's thunder but I might as well chime in here. Fortunately making a command-line script to do this is super simple. To parse CSV files you shouldn't have to write your own parser; do a search for the FasterCSV Ruby gem. As for the database, ActiveRecord with the SQLite adapter will do just fine. Basically you'll want to write a model class to represent your table, and use ActiveRecord::Base.establish_connection to connect to the database. Then you'll read the CSV file using FasterCSV and as you iterate through each row you use AR to save a row to the database. To drop the database, delete the file in Ruby and start over with a fresh CSV file.

Clear as mud..?
Jim F.
user 5009985
Madison, AL
Post #: 1
Here is a link to a similar stack overflow question that might get you close via command line. http://stackoverflow....­
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy