This is an example from the O'Reilly Cookbook (truncated dataset)
headers = ['Symbol','Price','Date','Time','Change','Volume']
rows = [{'Symbol': 'AA', 'Volume': 181800, 'Change': -0.18,
'Time': '9:36am', 'Date': '6/11/2007', 'Price': 39.48},
{'Symbol': 'AIG', 'Volume': 195500, 'Change': -0.15,
'Time': '9:36am', 'Date': '6/11/2007', 'Price': 71.38} ]
with open('stocks2.csv','w') as f:
f_csv = csv.DictWriter(f, headers)
f_csv.writeheader()
f_csv.writerows(rows)
the output file has a
at the end of each line, and apparently one more at the end. When I bring it into Excel, I get blank lines between each row. The same if I open it with Notepad++.
But, if I more
if from a command line, the
don't show up.
I saw another Q&A about a
at the end of a file - but this one is about a
at the end of each line. (And I don't see why more
doesn't give the
.)
I plan to bring the file into OpenOffice Calc.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…