iszhaoxin commited on
Commit
2d34974
·
1 Parent(s): 714e477
Files changed (1) hide show
  1. test.py +4 -19
test.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  from pdb import set_trace
3
 
4
  import datasets
 
5
 
6
  _CITATION = """\
7
  Put your dataset citation here.
@@ -81,22 +82,6 @@ class Test(datasets.GeneratorBasedBuilder):
81
 
82
  def _generate_examples(self, filepath):
83
  with open(filepath, encoding="utf-8") as f:
84
- for id_, line in enumerate(f):
85
- # Example: Parsing CSV file based on the subset name
86
- if self.config.name == "customers":
87
- # Subset A expects three columns: feature_a1, feature_a2, label
88
- _, feature_a1, feature_a2, label = line.strip().split(",")
89
- set_trace()
90
- yield id_, {
91
- "customer_id": feature_a1,
92
- "name": feature_a2,
93
- "age": int(label),
94
- }
95
- elif self.config.name == "products":
96
- # Subset B expects four columns: feature_b1, feature_b2, additional_info, label
97
- _, feature_b1, feature_b2, additional_info = line.strip().split(",")
98
- yield id_, {
99
- "product_id": feature_b1,
100
- "name": feature_b2,
101
- "price": float(additional_info),
102
- }
 
2
  from pdb import set_trace
3
 
4
  import datasets
5
+ import pandas as pd
6
 
7
  _CITATION = """\
8
  Put your dataset citation here.
 
82
 
83
  def _generate_examples(self, filepath):
84
  with open(filepath, encoding="utf-8") as f:
85
+ df = pd.read_csv(filepath, index_col=0)
86
+ for id_, item in df.iterrows():
87
+ yield id_, item.to_dict()