KwickClips Python · 42 sec · free
Why is there a blank row after every CSV row?
Short answer. The writer adds a line ending, and Windows text mode adds another.
How do you fix it?
Open the file with newline="".
Remember
| Always use newline="" |
| Mode w erases old rows |
A blank row after every CSV row? Here is why. The csv writer adds its own line ending. On Windows, text mode adds one more. Newline equals empty quotes stops it. Always use newline equals empty quotes. The mode w erases old rows.
This clip is from the full lesson: CSV Files with the csv Module — 6 minutes, with the tables, the quick answers and the whole lesson in text.
Useful for: CBSE Class 12 Computer Science (083), CBSE Class 12 Computer Science (083), CBSE Class 11 Artificial Intelligence (843), Programming All levels Python
More KwickClips from this lesson
What does CSV stand for?38 sec
What does writerows() take?41 sec
Is 88 read from a CSV a number?38 secDisclaimer. KwickAcademy is free study material for general learning and revision. Parts of it, including the voice-over, are produced with the help of AI tools and may contain errors; if you spot one, please tell us and we will correct it. Syllabus, marks and exam details follow the latest official board publications available to us, and boards can change them at any time, so always confirm against your board's official website and your school. Using this material does not guarantee any marks or result. Board names and trademarks belong to their owners; Kwickprep is not affiliated with or endorsed by any examination board. We never ask for passwords, OTPs or ID numbers. Your progress is saved only in this browser. Full disclaimer · Privacy

