I used python 2.7 to fetch historical data from Google finance. I would like to save the output in .csv with the stock individual names. Example, AAPL.csv,MSFT.csv and etc. Since I have 900 stocks in the list, I use a for loop to name my file but it is unable to name stock in csv (I mean the .csv extension is missing with the way I wrote my script). Please advice.
if __name__ == '__main__':
stocklist=['AAPL','MSFT','ABC','KKF']
stocklen=len(stocklist)
or x in range(1,stocklen,1):
q = GoogleQuote(stocklist[x],'2015-12-21')
print q
q.write_csv(stocklist[x])
This is the snippet for the code as it is too long. Since the stocks also included foreign stocks, I am unable to use pandas datareader.
I could have use thisq.write_csv('ABC.csv')
but it is not practical since I have 900 stocks and need to name it one by one.
I afraid with current type of file without .csv, I could not perform data analysis using pandas.
[snapshot of the file without .csv extension1