Progrider

Programming discussion

Board index
Findings · ✓ Resolved · csv python

Fixed: double spacing in CSV export

Leaving this here because I spent an hour on it. My Python CSV export had blank lines between every record when opened on Windows.

Opening the output with newline="" fixed it:

with open("out.csv", "w", newline="") as f:
    writer = csv.writer(f)

I had been trying to strip the strings before writing them.

1 reply

Thanks, had the same thing with a script exporting addresses. newline="" did it.

Discussion resolved

This discussion is resolved. Its creator can reopen it to accept more replies.