Johnnyeee commited on
Commit
b5cb6d7
1 Parent(s): ef43c79

Update Yelpdata_663.py

Browse files
Files changed (1) hide show
  1. 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
- # Convert specific fields to integers from floats
123
- if 'is_open' in row and row['is_open']:
124
- row['is_open'] = int(float(row['is_open']))
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