faster csv issue

J

Junkone

not sure why fastercsv cannot parse this. cannot find anything wrong
with my code either. why does it show invalid arguement. for eg

puts ie.text
"ClientAccountID","CurrencyPrimary","AssetClass","Symbol","OptionFutureCode","Quantity","MarkPrice","CostBasisPrice"

"6814789","USD","STK","CSUN","","125","11.9800","12.1750"

"6814789","USD","STK","SIMO","","150","20.0500","19.186667"
arr_of_arrs = FasterCSV.read(ie.text,{:col_sep => ",",:headers=>true})
Invalid argument -
"ClientAccountID","CurrencyPrimary","AssetClass","Symbol","OptionFutureCode","Quantity","MarkPrice","CostBasisPrice"

"6814789","USD","STK","CSUN","","125","11.9800","12.1750"

"6814789","USD","STK","SIMO","","150","20.0500","19.186667"
 
J

James Gray

not sure why fastercsv cannot parse this. cannot find anything wrong
with my code either. why does it show invalid arguement.

I don't see the "Invalid Argument error here, but you should be using
parse() instead of read(), if the content comes from a String:

#!/usr/bin/env ruby -wKU

require "rubygems"
require "faster_csv"

csv = <<END_CSV
"ClientAccountID
","CurrencyPrimary
","AssetClass
","Symbol","OptionFutureCode","Quantity","MarkPrice","CostBasisPrice"
"6814789","USD","STK","CSUN","","125","11.9800","12.1750"
"6814789","USD","STK","SIMO","","150","20.0500","19.186667"
END_CSV

p FCSV.parse(csv, :col_sep => ",", :headers => true)

__END__

Hope that helps.

James Edward Gray II
 
J

Junkone

I don't see the "Invalid Argument error here, but you should be using  
parse() instead of read(), if the content comes from a String:

#!/usr/bin/env ruby -wKU

require "rubygems"
require "faster_csv"

csv = <<END_CSV
"ClientAccountID
","CurrencyPrimary
","AssetClass
","Symbol","OptionFutureCode","Quantity","MarkPrice","CostBasisPrice"
"6814789","USD","STK","CSUN","","125","11.9800","12.1750"
"6814789","USD","STK","SIMO","","150","20.0500","19.186667"
END_CSV

p FCSV.parse(csv, :col_sep => ",", :headers => true)

__END__

Hope that helps.

James Edward Gray II

thanks james.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top