imvladikon commited on
Commit
f01a46e
1 Parent(s): fce1bd6

Update hebrew_news.py

Browse files
Files changed (1) hide show
  1. hebrew_news.py +14 -14
hebrew_news.py CHANGED
@@ -6,6 +6,8 @@ import os.path
6
 
7
  import datasets
8
  from urllib.parse import urlparse
 
 
9
 
10
  _CITATION = """
11
  """
@@ -66,17 +68,15 @@ class HebrewNews(datasets.GeneratorBasedBuilder):
66
 
67
  def _generate_examples(self, archive_iter):
68
  for filepath, f in archive_iter:
69
- print(type(f))
70
- with open(filepath, encoding="utf-8") as f:
71
- fieldnames = ["articleBody", "description", "headline", "title"]
72
- reader = csv.DictReader(f, delimiter=",", fieldnames=fieldnames)
73
- next(reader)
74
- for idx, row in enumerate(reader):
75
- yield idx, {
76
- "id": idx,
77
- "articleBody": row["articleBody"],
78
- "description": row["description"],
79
- "headline": row["headline"],
80
- "title": row["title"],
81
- }
82
-
 
6
 
7
  import datasets
8
  from urllib.parse import urlparse
9
+ import io
10
+
11
 
12
  _CITATION = """
13
  """
 
68
 
69
  def _generate_examples(self, archive_iter):
70
  for filepath, f in archive_iter:
71
+ csv_file = io.TextIOWrapper(f, encoding="utf-8")
72
+ fieldnames = ["articleBody", "description", "headline", "title"]
73
+ reader = csv.DictReader(csv_file, delimiter=",", fieldnames=fieldnames)
74
+ next(reader)
75
+ for idx, row in enumerate(reader):
76
+ yield idx, {
77
+ "id": idx,
78
+ "articleBody": row["articleBody"],
79
+ "description": row["description"],
80
+ "headline": row["headline"],
81
+ "title": row["title"],
82
+ }