fastercsv error

J

Junkone

When i try to parse this file, i get a error.

irb(main):006:0> rows=FasterCSV.new("c:\\temp\\mktsymbols.txt",
{:headers=>true,:
col_sep=>"\t"})
=> #<FasterCSV:0x2ddfc3c @lineno=0, @header_converters=[],
@converters=[], @unco
nverted_fields=nil, @parsers={:line_end=>/\n\z/, :leading_fields=>/
\A(?:\t)+/, :
csv_row=>/ \G(?:^|\t) # anchor the match
(?: "( (?>[^"]*) # find quoted fields
(?> ""
[^"]* )* )"
| # ... or ...
([^"\t]*) # unquoted fields
)/x}, @row_sep="\n", @return_headers=false,
@headers=nil, @col_sep
="\t", @use_headers=true, @skip_blanks=false, @io=#<StringIO:
0x2ddfc00>, @quote=
#<Proc:0x02e05f90@e:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.1/lib/
faster_csv.
rb:1665>, @quote_char="\"">



the file contents are
SYMBOL DESCRIPTION EXCHANGE
EDS RX EDS JUN 2008 P 22.500 OPRA
EDS RY EDS JUN 2008 P 27.500 OPRA
EDS RZ EDS JUN 2008 P 32.500 OPRA
EDS XD EDS DEC 2007 P 20.000 OPRA
EDS XE EDS DEC 2007 P 25.000 OPRA
EDS XF EDS DEC 2007 P 30.000 OPRA
EDS XG EDS DEC 2007 P 35.000 OPRA
EDS XH EDS DEC 2007 P 40.000 OPRA
EDS XT EDS DEC 2007 P 17.500 OPRA
EDS XU EDS DEC 2007 P 37.500 OPRA
EDS XX EDS DEC 2007 P 22.500 OPRA
EDS XY EDS DEC 2007 P 27.500 OPRA
EDS XZ EDS DEC 2007 P 32.500 OPRA
EDS1CN07 EDS JUL 2007 ONECH
EDS1CQ07 EDS AUG 2007 ONECH
EDS1CU07 EDS SEP 2007 ONECH
EDS1CZ07 EDS DEC 2007 ONECH
EDSAX EVERGREEN DISCIPLINED VALUE FUND CLASS NASDAQ
EDSBX EVERGREEN DISCIPLINED VALUE FUND CLASS NASDAQ
EDSCX EVERGREEN DISCIPLINED VALUE FUND CLASS NASDAQ
EDSI EDUCATIONAL SERVICES OTC
EDSIX EVERGREEN DISCIPLINED VALUE FUND INSTI NASDAQ
EDTA E-DATA CORPORATION OTC
EDTDF ENEA AB OTC
EDTXX EVERGREEN INSTI TREASURY MONEY MARKET F NASDAQ
 
J

Junkone

Can you show the error please?

James Edward Gray II

when i try to print the row, it returns nil. pl see below. it means
that this tool could not parse the data.
irb(main):045:0> rows=FasterCSV.new("c:\\temp\\mktsymbols.txt",
{:headers=>true,:
col_sep=>"\t"})
=> #<FasterCSV:0x2e38378 @lineno=0, @header_converters=[],
@converters=[], @unco
nverted_fields=nil, @parsers={:line_end=>/\n\z/, :leading_fields=>/
\A(?:\t)+/, :
csv_row=>/ \G(?:^|\t) # anchor the match
(?: "( (?>[^"]*) # find quoted fields
(?> ""
[^"]* )* )"
| # ... or ...
([^"\t]*) # unquoted fields
)/x}, @row_sep="\n", @return_headers=false,
@headers=nil, @col_sep
="\t", @use_headers=true, @skip_blanks=false, @io=#<StringIO:
0x2e3833c>, @quote=
#<Proc:0x02e05f90@e:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.1/lib/
faster_csv.
rb:1665>, @quote_char="\"">


irb(main):047:0> rows.each{|r| puts "row found"}
=> nil
irb(main):047:0>
 
J

James Gray

when i try to print the row, it returns nil. pl see below. it means
that this tool could not parse the data.

The "nil" returned is the return value of your puts() call, shown by
IRb.

The issue is that you are using FasterCSV.new(). It's intended for
when you want to pass in your own IO-like object. You are passing in
the path of a file to open though, so you want FasterCSV.open().

James Edward Gray II
 

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top