We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fd0ddc0 commit 5c998dcCopy full SHA for 5c998dc
binary-search/download_imdb.py
@@ -7,6 +7,7 @@
7
$ python download_imdb.py
8
"""
9
10
+import csv
11
import gzip
12
import shutil
13
import tempfile
@@ -36,11 +37,12 @@ def names():
36
37
with tempfile.NamedTemporaryFile(mode="w+b") as archive:
38
shutil.copyfileobj(response, archive)
39
archive.seek(0)
- with gzip.open(archive, mode="rt") as source:
40
- next(source) # Skip the header
41
- for line in source:
42
- full_name = line.split("\t")[1]
43
- yield f"{full_name}\n"
+ with gzip.open(archive, mode="rt") as tsv_file:
+ tsv = csv.reader(tsv_file, delimiter='\t')
+ next(tsv) # Skip the header
+ for record in tsv:
44
+ full_name = record[1]
45
+ yield f'{full_name}\n'
46
47
48
if __name__ == "__main__":
0 commit comments