Ross Bamford
6/9/2006 6:19:00 PM
On Fri, 09 Jun 2006 18:54:44 +0100, Charles L. Snyder <clsnyder@gmail.com>
wrote:
>
> coachhilton@gmail.com wrote:
>> Are you certain Yahoo is not giving you back quotes strings?
>
> I don't think that is the problem, because I tried this:
>
>> > Note - when i try a
>> > puts n
>> > puts n.class
>> >
>> > in the line just above this one : w.push(stock_struct.new(n[0], n[1],
>> > n[2],date_now, 5, "Domestic Equity","Precious Metal"))
>> > I get
>> > "AAPL"
>> > string
>> > "BGEIX"
>> > string
>
But those strings *do* contain quotes - puts translates \ stuff for
output. If you did p n rather than puts n, You'd see:
"\"AAPL\""
string
"\"BGEIX\""
string
(p uses inspect, showing the actual form of the string). The backslashed
quote here is the quote that becomes visible in your puts output.
One easy way I can see to fix this, since you're already requiring CSV in
your script, is to change this line:
n = n.split(/,/)
to this:
n = CSV.parse_line(n)
and let CSV worry about correctly parsing out the quoted fields.
--
Ross Bamford - rosco@roscopeco.remove.co.uk