Datasets:
Update Yelpdata_663.py
Browse files- Yelpdata_663.py +4 -5
Yelpdata_663.py
CHANGED
|
@@ -113,14 +113,13 @@ class YelpDataset(datasets.GeneratorBasedBuilder):
|
|
| 113 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
| 114 |
]
|
| 115 |
|
|
|
|
| 116 |
def _generate_examples(self, filepath):
|
| 117 |
"""This function returns the examples in the raw (text) form."""
|
| 118 |
logging.info("generating examples from = %s", filepath)
|
| 119 |
with open(filepath, encoding="utf-8") as csv_file:
|
| 120 |
reader = csv.DictReader(csv_file)
|
| 121 |
for i, row in enumerate(reader):
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
# Similarly convert other fields that need preprocessing
|
| 126 |
-
yield i, row
|
|
|
|
| 113 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
| 114 |
]
|
| 115 |
|
| 116 |
+
|
| 117 |
def _generate_examples(self, filepath):
|
| 118 |
"""This function returns the examples in the raw (text) form."""
|
| 119 |
logging.info("generating examples from = %s", filepath)
|
| 120 |
with open(filepath, encoding="utf-8") as csv_file:
|
| 121 |
reader = csv.DictReader(csv_file)
|
| 122 |
for i, row in enumerate(reader):
|
| 123 |
+
# Convert the row to a dictionary, removing any null values
|
| 124 |
+
example = {key: value for key, value in row.items() if value is not None}
|
| 125 |
+
yield i, example
|
|
|
|
|
|