I have a list of numbers that I want to put in a single column in a .csv file. The code below writes the values across a single row. How can I change the code so that Python writes the each value on a separate row? Thanks.
with open('returns.csv', 'wb') as f:
writer = csv.writer(f)
writer.writerow(daily_returns)
f.writelines([ret + '\n' for ret in daily_returns])
– Samurairet
values could contain'\n'
characters or delimiters that would need quoting. – Etheleneethelin