I am trying to write to an empty CSV file.
I want the output on the CSV file to be something like this:
Date,Open,High,Low,Close,Volume,Adj Close
2014-03-28,538.32,538.94,534.25,536.86,7106900,536.86
2014-03-27,540.02,541.50,535.12,537.46,7929700,537.46
2014-03-26,546.52,549.00,538.86,539.78,10706000,539.78
2014-03-25,541.50,545.75,539.59,544.99,10081900,544.99
2014-03-24,538.42,540.50,535.06,539.19,12703600,539.19
2014-03-21,531.93,533.75,526.33,532.87,13373200,532.87
2014-03-20,529.89,532.67,527.35,528.70,7442800,528.70
2014-03-19,532.26,536.24,529.00,531.26,8027000,531.26
2014-03-18,525.90,531.97,525.20,531.40,7487400,531.40
2014-03-17,527.70,529.97,525.85,526.74,7126600,526.74
But I end up getting a very large number of rows, every character is a different cell.
My code is:
with open('prova.csv','w',newline='') as f:
writer = csv.writer(f,delimiter=',',quotechar='"')
writer.writerows(request3)
f.flush()
f.close()
And the output of request 3 is the same table as above.
closethe file, and I'm 99% sure you also don't need toflushit. Please show us the contents ofrequest3as a python object so we can figure it out.