Reputation: 3882
I have the following code.
from urllib2 import urlopen
from csv import reader
up_url = "http://finviz.com/export.ashx?v=111&f=ind_stocksonly,sh_price_o10,ta_change_u,ta_changeopen_u,ta_highlow20d_nh,ta_highlow50d_nh,ta_highlow52w_nh,ta_sma20_pa,ta_sma200_pa,ta_sma50_pa&ft=4&o=-change"
up_text = urlopen(up_url).readline()
for row in reader(up_text):
print row
So I anticipate something along the lines of:
["No.","Ticker","Company","Sector","Industry","Country","MarketCap","P/E","Price","Change","Volume"]
['No.']
['', '']
['Ticker']
['', '']
['Company']
['', '']
['Sector']
['', '']
['Industry']
['', '']
['Country']
['', '']
['Market Cap']
['', '']
['P/E']
['', '']
['Price']
['', '']
['Change']
['', '']
['Volume']
[]
[]
As I understood it, csv should create lists by splitting up strings by '\n' and then by ','. So what is going on here?
Upvotes: 2
Views: 77
Reputation: 299
Remove the .readline() method from the one line:
up_text = urlopen(up_url)
Upvotes: 2