Delete loading script
Browse files
test.py
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
from pdb import set_trace
|
3 |
-
|
4 |
-
import datasets
|
5 |
-
import pandas as pd
|
6 |
-
|
7 |
-
_CITATION = """\
|
8 |
-
Put your dataset citation here.
|
9 |
-
"""
|
10 |
-
|
11 |
-
_DESCRIPTION = """\
|
12 |
-
Description of your dataset goes here.
|
13 |
-
"""
|
14 |
-
|
15 |
-
_HOMEPAGE = "https://your-dataset-homepage.com"
|
16 |
-
|
17 |
-
_LICENSE = "License information goes here."
|
18 |
-
|
19 |
-
|
20 |
-
class Test(datasets.GeneratorBasedBuilder):
|
21 |
-
"""Your dataset description"""
|
22 |
-
|
23 |
-
BUILDER_CONFIGS = [
|
24 |
-
datasets.BuilderConfig(
|
25 |
-
name="customers",
|
26 |
-
data_dir="./",
|
27 |
-
version=datasets.Version("1.0.0"),
|
28 |
-
description="This is subset A"),
|
29 |
-
datasets.BuilderConfig(
|
30 |
-
name="products",
|
31 |
-
data_dir="./",
|
32 |
-
version=datasets.Version("1.0.0"),
|
33 |
-
description="This is subset B"),
|
34 |
-
]
|
35 |
-
|
36 |
-
def _info(self):
|
37 |
-
if self.config.name == "customers":
|
38 |
-
features = datasets.Features(
|
39 |
-
{
|
40 |
-
"customer_id": datasets.Value("int32"),
|
41 |
-
"name": datasets.Value("string"),
|
42 |
-
"age": datasets.Value("int32"),
|
43 |
-
}
|
44 |
-
)
|
45 |
-
elif self.config.name == "products":
|
46 |
-
features = datasets.Features(
|
47 |
-
{
|
48 |
-
"product_id": datasets.Value("int32"),
|
49 |
-
"name": datasets.Value("string"),
|
50 |
-
"price": datasets.Value("float32"),
|
51 |
-
}
|
52 |
-
)
|
53 |
-
else:
|
54 |
-
raise ValueError(f"Unknown subset: {self.config.name}")
|
55 |
-
|
56 |
-
return datasets.DatasetInfo(
|
57 |
-
description=_DESCRIPTION,
|
58 |
-
features=features,
|
59 |
-
supervised_keys=None,
|
60 |
-
homepage=_HOMEPAGE,
|
61 |
-
license=_LICENSE,
|
62 |
-
citation=_CITATION,
|
63 |
-
)
|
64 |
-
|
65 |
-
def _split_generators(self, dl_manager):
|
66 |
-
data_dir = os.path.join(self.config.data_dir, self.config.name)
|
67 |
-
# set_trace()
|
68 |
-
return [
|
69 |
-
datasets.SplitGenerator(
|
70 |
-
name=datasets.Split.TRAIN,
|
71 |
-
gen_kwargs={"filepath": os.path.join(data_dir, "train.csv")},
|
72 |
-
),
|
73 |
-
datasets.SplitGenerator(
|
74 |
-
name=datasets.Split.VALIDATION,
|
75 |
-
gen_kwargs={"filepath": os.path.join(data_dir, "val.csv")},
|
76 |
-
),
|
77 |
-
datasets.SplitGenerator(
|
78 |
-
name=datasets.Split.TEST,
|
79 |
-
gen_kwargs={"filepath": os.path.join(data_dir, "test.csv")},
|
80 |
-
),
|
81 |
-
]
|
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 |
-
# set_trace()
|
88 |
-
yield id_, item.to_dict()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|