I have a fasterCSV rake script but it only imports to 1 table. I am importing products and the products have several pieces of info stored on other tables.
Current script: http://gist.github.com/321889
What I need to add is some way to import product info to another table at the same time. Say a category name.
In this case: the ro...
I have a rails app with some nested data that I'd like to export as a CSV file
The models look like:
class ContainerRecord < ActiveRecord::Base
has_many :child_records
and
class ChildRecord < ActiveRecord::Base
belongs_to :container_record
I'd like to be able to export a CSV file with each ContainerRecord on a row with i...
Hi there,
I'm trying to generalize a data retrieval mechanism with Ruby, and can't seem to find a way to retrieve a CSV file and access one of the row's columns by using a dot operator like so:
Let's say I have a CSV table:
#some_file.csv
name,age
albert,13
And I create a FasterCSV table from it:
a = FasterCSV.new(File.open('some_fi...
We're having a significant number of problems creating a bulk upload function for our little app. We're using the FasterCSV gem to upload data to a MySQL database but he Faster CSV is so twitchy and precise in its requirements that it constantly breaks with malformed CSV errors and time out errors.
The csv files are generally created b...
Exporting some data from mysql to a csv file using FasterCSV. I'd like the columns in the outputted CSV to be in the same order as the select statement in my query.
Example:
rows = Data.find(
:all,
:select=>'name, age, height, weight'
)
headers = rows[0].attributes.keys
FasterCSV.generate do |csv|
csv << headers
rows.each do ...
Hey. How can I get a total number of rows in a file (do not want to do it with loop). I'm reading CSV file.
Example 1
CSV.open('clients.csv', 'r')
Example 2
FasterCSV.foreach('clients.csv')
Thx.
...
I have a CSV file formatted just like this:
name,color,tasty,qty
apple,red,true,3
orange,orange,false,4
pear,greenish-yellowish,true,1
As you can see, each column in the Ruby OO world represents a mix of types -- string, string, boolean, int.
Now, ultimately, I want to parse each line in the file, determine the appropriate type, and ...
I'm currently importing a CSV into an activerecord element but can't choose to parse the elements as say ints or decimals on a case by case basis using fastercsv. I can either choose to parse everything as an int or the other, or all as strings. I need to parse some columns as ints, some as decimals and some as strings.
Otherwise, is th...
G'day guys, I'm currently using fastercsv to construct ActiveRecord elements and I can't for the life of me see this bug (tired), but for some reason when it creates, if in the rake file i output the column I want to save as the element value, it puts out correctly, as either a Trade or a Quote
but when I try to save it into the activer...
G'day guys, currently have almost finished writing a rails application that allows a CSV download of the database. This is generated when the index is first viewed.
Is there an easy way to insert a link to a helper that returns a CSV document? That is to say is it easy to insert links to helpers? This would make a lot of problems I've ...
G'day guys, I'm currently using fasterCSV to parse a CSV file in ruby, and wondering how to get rid of the initial row of data on a CSV (The initial row contains the time/date information generated by another software package)
I tried using fasterCSV.table and then deleting row(0) then converting it to a CSV document then parsing it
bu...
Hi, what is the right way to check csv separator character, either using ";" or "," in a different computer regional setting ? I want my fastercsv able to parse both of them without complaining at all, what is the right way to do it ?
...
Ok so I am trying to import a csv which I need to insert into a db through rails or anyway that would be quickest so i decided to create a dummy rails application to do the importing. Here is some of the code below which I got some of it from a blog I was reading.
def upload
table = ImportTable.new :original_path => params[:upload][:c...
This may well be a duplicate, but I couldn't find anyone asking quite this question.
My understanding* is that if I want to migrate data from an outside source to my Rails app's database, I should do so using a migration. It seems from my preliminary research that what I could do is use a tool like FasterCSV to parse a CSV file (for exa...
I've been having a problem uploading a CSV file to Heroku and processing it. It works fine in my local environment. Just do be clear, I don't need to save the file on Heroku, just access it during the request in order to convert it into a string for processing and importing into the DB.
What I want to do is:
Upload CSV file
Strip out ...
I have a model (called Test):
property :id, Serial
property :title, String, :length => 255, :required => true
property :description, String, :length => 255, :required => true
property :brand, String, :length => 255, :required => true
property :link, String, :length => 255, :required => ...
the following code:
[1,3,5].to_csv
=> "1,3,5\n" # this is good
[[1,3,5], [2,4,6]].to_csv
=> "135,246\n" # why doesn't it just do it for array of array?
but require this instead:
data = [[1,3,5], [2,4,6]]
csv_string = FasterCSV.generate do |csv|
data.each {|a| csv << a}
end
=> "1,3,5\n2,4,6\n"
or shorter:
data =...
I am using the csv-mapper gem to import a csv file. When I use the example code on in the README (http://github.com/pillowfactory/csv-mapper) in script/console it works great. However, when I create a web form and use that to upload a csv file I get the error "No such file or directory - test.csv
These are the parameters:
Parameters:
{...
hi guys,
do fastercsv (rails) have the function of reading only the header of a csv file.
This is because i need to validate the format of the header before processing other rows.
Thanks
...