Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 51c7db7

Browse files
committed
Fix csv newline handling in movie-lister example
1 parent a322584 commit 51c7db7

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

‎examples/miniapps/movie-lister/data/fixtures.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818

1919

2020
def create_csv(movies_data, path):
21-
with open(path, "w") as opened_file:
21+
with open(path, "w", newline="") as opened_file:
2222
writer = csv.writer(opened_file)
23-
for row in movies_data:
24-
writer.writerow(row)
23+
writer.writerows(movies_data)
2524

2625

2726
def create_sqlite(movies_data, path):

‎examples/miniapps/movie-lister/movies/finders.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(
2929
super().__init__(movie_factory)
3030

3131
def find_all(self) -> List[Movie]:
32-
with open(self._csv_file_path) as csv_file:
32+
with open(self._csv_file_path, newline="") as csv_file:
3333
csv_reader = csv.reader(csv_file, delimiter=self._delimiter)
3434
return [self._movie_factory(*row) for row in csv_reader]
3535

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /