Progrider

Programming discussion

Search

Searches topics and replies. Every word has to appear in the post.

9 posts found.

PostPosted
Findings · post #2

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


by Anonymous
Findings · post #1

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(…


by Anonymous
Help · post #3

Worked first try. Resolved.


by Anonymous
Help · post #2

The csv module in the standard library. csv.reader handles quotes and embedded commas. Open the file with newline="" for reading too, same reason as writing.


by Anonymous
Help · post #1

Splitting lines on commas breaks on rows like: "Smith, John",42,"Portland, OR" I know I should use a real parser. Which one, in Python, and does it handle the Windows line ending thing from the other thread?


by Anonymous
Help · post #4

That fixed it, thanks both! José is back.


by bea
Help · post #3

And keep newline="" on that open() call if you're using the csv module.


by lintroller !-TjZOnKc
Help · post #2

Nothing wrong, Excel is guessing. Without a BOM it assumes the Windows codepage when you double click a CSV. Use encoding="utf-8-sig" and it'll write the three BOM bytes at the start, and Excel will then read it as UTF-8. Don't use it for f…


by ines
Help · post #1

My class list has names like José and Zoë. I write it from Python with open("list.csv", "w", encoding="utf-8") and LibreOffice shows it correctly. On the school computers with Excel it shows José. What did I do wrong?


by bea
All times shown in UTC.