Questions tagged [fastercsv]

Popular Ruby library/gem for working with CSV format files.

FasterCSV is a very popular Ruby gem for workin with CSV (comma-separated values) format files and data. It can import, export, and perform various other operations on data in CSV format.

164 questions
0
votes
1 answer

Ruby - FasterCSV after Parsing JSON

I am trying to parse through a JSON response for customer data (names and email) and construct a csv file with column headings of the same. For some reason, every time I run this code I get a CSV file with a list of all the first names in one cell…
ns1
  • 117
  • 2
  • 3
  • 10
0
votes
1 answer

JSON to CSV via FasterCSV

I'm new to Ruby and had a question. I'm trying to create a .rb file that converts JSON to CSV. I came across some disparate sources that got me to make: require "rubygems" require 'fastercsv' require 'json' csv_string = FasterCSV.generate({}) do…
Doz
  • 7,009
  • 12
  • 61
  • 69
0
votes
2 answers

Parse remote file with FasterCSV

I'm trying to parse the first 5 lines of a remote CSV file. However, when I do, it raises Errno::ENOENT exception, and says: No such file or directory - [file contents] (with [file contents] being a dump of the CSV contents Here's my code: def…
Asherlc
  • 1,111
  • 2
  • 12
  • 28
0
votes
1 answer

Does FasterCSV open entire file on read?

In a situation like so: FasterCSV.parse(uploaded_file) do |row| @rows[i] = row i += 1 break row if i == 10 end Does FasterCSV read the entire file, or just the first 10 rows? I want to display the first couple lines of a CSV file, but don't…
Asherlc
  • 1,111
  • 2
  • 12
  • 28
0
votes
2 answers

FasterCSV - instead of getting the content file getting the path to file

def csv_parsing require 'csv' csv_file_path = File.join(File.dirname(__FILE__), "csv_data.csv") CSV.parse(csv_file_path) do |line| puts line[0] end end This is a simple example, how I try to parse CSV file. The action…
user984621
  • 46,344
  • 73
  • 224
  • 412
0
votes
2 answers

uploading and import csv to rails

i have followed this tut enter link description here, though i seem to have encountered a few issues. the problem i am getting is NameError undefined local variable or method `map' for # which i…
Boss Nass
  • 3,384
  • 9
  • 48
  • 90
0
votes
1 answer

Pulling a value from one CSV based on a value in another

I am trying to figure out the best way to pull a value from a CSV file called lookup.csv based on a value in master.csv, and then save the new file as output.csv. In the example below, the master file has three columns of data with the last column…
mpowmap
  • 651
  • 1
  • 6
  • 11
0
votes
1 answer

Rails 3 - Importing Multiple Lines from text_area

What's the best approach to import multiple lines from a text_area in a form? I've tried a quick bodge using FasterCSV but get a NoMethodError: undefined method `pos' for {"name"=>"Carrots\r\nPeas\r\nRed Onion"}* def create …
Raoot
  • 1,751
  • 1
  • 25
  • 51
0
votes
1 answer

ror export csv bring a serious performance problems

export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| .. end format.csv {send_data(export), :type => 'text/csv;header=present',:filename => 'export.csv') } I want to export large amounts of data.But it bring a serious performance…
0
votes
1 answer

No such file to load -- FasterCSV

This problem has been bugging me for hours already. I am deploying a Rails3 App in a shared hosting site. I have been able to run the site on my local Ubuntu. It works well. But as I try to deploy it online, it does not work well. So I think it…
nmenego
  • 846
  • 3
  • 17
  • 36
0
votes
1 answer

Import using FasterCSV / Rails 3.1 / Ruby 1.8.7

I'm attempting to import a tab separated file using FasterCSV. I've tried various things and get varying errors. In it's current state i'm getting a "undefined method `tempfile'" error. I've added the fastercsv code to my create action as bulk…
Raoot
  • 1,751
  • 1
  • 25
  • 51
0
votes
1 answer

ruby fastercsv, pre- and append identical text to every cell in file

I've read through the docs but still can't see how to target individual cells and pre- or append strings to cell content. File is fairly large, if that matters (90MBs). CSV: 2.22,3.33,4.44,5.55 6.66,7.77,8.88,9.99 I need this…
chuckfinley
  • 763
  • 11
  • 26
0
votes
3 answers

encoding issue with CSV.parse

My goal is to upload a file containing rows of firstname and lastname, parse it and create Person model in db for each row. I do the following and it works fine file = CSV.parse(the_file_to_parse) file.each do |row| person = Person.new(:firstname…
denisjacquemin
  • 7,414
  • 10
  • 55
  • 72
-1
votes
1 answer

JSON Array to CSV via FasterCSV

I have a JSON array in the following format. [{"Name":"Ann","Gender":"Female","Age":"20"},{"Name":"John","Gender":"Male","Age":"22"}] I want to convert this into following CSV format without printing the "Key" and also i want it to print only the…
Chamara Keragala
  • 5,627
  • 10
  • 40
  • 58
1 2 3
10
11