Python CSV parsing not returning proper rows
I'm new to python and having issues with the CSV parser. Here is the code:
import urllib2
import csv
u =
urllib2.urlopen(r'http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+MSFT&f=nab')
data = u.read()
reader = csv.reader(data)
for row in reader:
print row
Yahoo returns this raw csv:
"Apple Inc.",482.09,482.00
"Google Inc.",877.20,876.94
"Microsoft Corpora",33.34,33.33
I want to parse this and create a simple JSON object with 3 fields:
Ticker, Bid, Offer
But the data comes in from that csv.reader() like so:
['Apple Inc.'] ['', ''] ['4'] ['8'] ['2'] ['.'] ['5'] ['5'] ['', ''] ['4']
['8'] ['2'] ['.'] ['4'] ['8'] [] [] ['Google Inc.'] ['', ''] ['8'] ['7']
['6'] ['.'] ['2'] ['4'] ['', ''] ['8'] ['7'] ['6'] ['.'] ['1'] ['0'] [] []
['Microsoft Corpora'] ['', ''] ['3'] ['3'] ['.'] ['2'] ['9'] ['', '']
['3'] ['3'] ['.'] ['2'] ['8'] [] []
It seems to be breaking the rows on each number. Any ideas as to what I'm
doing wrong here?
No comments:
Post a Comment