Skip to content

Commit 2f54078

Browse files
Fixed CSV file Save
Added newline='' to print a remove the new line that was being created at the end of each saved row in the CSV file.
1 parent 14392c0 commit 2f54078

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Chapter05/csv_editor.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def removeRows(self, position, rows, parent):
8585

8686
# method for saving
8787
def save_data(self):
88-
with open(self.filename, 'w', encoding='utf-8') as fh:
88+
# commented out code below to fix issue with additional lines being added after saving csv file from the window.
89+
# with open(self.filename, 'w', encoding='utf-8') as fh:
90+
with open(self.filename, 'w', newline='', encoding='utf-8') as fh:
8991
writer = csv.writer(fh)
9092
writer.writerow(self._headers)
9193
writer.writerows(self._data)

0 commit comments

Comments
 (0)