So I am trying to add a list of ticker symbols from a CSV file into a python list.
The CSV File looks like this:
AAPL
XOM
EMC
When working with the stockList[]. How do I remove the [' '] brackets and quote marks?
My code is below:
stockList = []
csvReader = csv.reader(open('tickers.csv','rb'), quoting=csv.QUOTE_NONE)
for row in csvReader:
stockList.append(row)
for item in stockList:
print repr(item)
For example when the code above is ran it outputs:
['AAPL']
['XOM']
['EMC']
解决方案
It looks like CSVReader is returning a list of rows. Modify your code in this way.
for row in csvReader:
row = "".join(row)
stockList.append(row)