Topic: Importing CSV files into a database

I'd like to allow users to upload a csv file and then add contents of the csv file to my tables. What I'm looking for is a way to receive the file from a form input, then parse out the contents of the file, I guess into a series of arrays, then add the array contents into the tables. The step where I'm most hung up is how to receive the csv file and extract the contents into an array that I can work with. Is there a plugin, gem, or other simple solution for this?

Re: Importing CSV files into a database

Assume you have a file_field in your form for something,  it's name is 'file', when you post the form, in the create action:

file = params[:something][:file]
data =
lines = data.split("\r")
lines.each do |l|
  cols = l.split(',')
  cols.each do |c|
    # c will refer to the contents of each column in the csv

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Importing CSV files into a database

Thanks! Looks like the read method is what I needed.