Add script
Browse files- tmp-one-config.py +25 -0
tmp-one-config.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv
|
| 2 |
+
|
| 3 |
+
import datasets
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
_URL = "data.csv"
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class TmpOneConfig(datasets.GeneratorBasedBuilder):
|
| 10 |
+
BUILDER_CONFIGS = [datasets.BuilderConfig(name="main")]
|
| 11 |
+
|
| 12 |
+
def _info(self):
|
| 13 |
+
return datasets.DatasetInfo(
|
| 14 |
+
features=datasets.Features({"text": datasets.Value("string"), "label": datasets.Value("int32")}),
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
def _split_generators(self, dl_manager):
|
| 18 |
+
data_path = dl_manager.download(_URL)
|
| 19 |
+
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"data_path": data_path})]
|
| 20 |
+
|
| 21 |
+
def _generate_examples(self, data_path):
|
| 22 |
+
with open(data_path, newline="", encoding="utf-8") as f:
|
| 23 |
+
for idx, row in enumerate(csv.DictReader(f)):
|
| 24 |
+
yield idx, row
|
| 25 |
+
|