lijianbin commited on
Commit
ec2e052
·
1 Parent(s): 84f964b
Files changed (5) hide show
  1. data.xlsx +0 -0
  2. test.xlsx +0 -0
  3. test_script.py +11 -18
  4. train.xlsx +0 -0
  5. validation.xlsx +0 -0
data.xlsx DELETED
Binary file (128 kB)
 
test.xlsx ADDED
Binary file (21.9 kB). View file
 
test_script.py CHANGED
@@ -40,11 +40,11 @@ _LICENSE = "123"
40
  # "first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
41
  # "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
42
  # }
43
- _URLS = 'https://huggingface.co/datasets/lijianbin/share_test/'
44
 
45
 
46
  # TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
47
- class ShareTest(datasets.GeneratorBasedBuilder):
48
  """TODO: Short description of my dataset."""
49
 
50
  VERSION = datasets.Version("1.0.0")
@@ -81,7 +81,7 @@ class ShareTest(datasets.GeneratorBasedBuilder):
81
  "x8": datasets.Value("float"),
82
  "x9": datasets.Value("float"),
83
  "x10": datasets.Value("float"),
84
- 'shape': (1000, 11)
85
  # These are the features of your dataset like images, labels ...
86
  }
87
  )
@@ -111,12 +111,13 @@ class ShareTest(datasets.GeneratorBasedBuilder):
111
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
112
  urls = _URLS
113
  data_dir = dl_manager.download_and_extract(urls)
 
114
  return [
115
  datasets.SplitGenerator(
116
  name=datasets.Split.TRAIN,
117
  # These kwargs will be passed to _generate_examples
118
  gen_kwargs={
119
- "filepath": os.path.join(data_dir, "data.xlsx"),
120
  "split": "train",
121
  },
122
  ),
@@ -124,7 +125,7 @@ class ShareTest(datasets.GeneratorBasedBuilder):
124
  name=datasets.Split.VALIDATION,
125
  # These kwargs will be passed to _generate_examples
126
  gen_kwargs={
127
- "filepath": os.path.join(data_dir, "data.xlsx"),
128
  "split": "validation",
129
  },
130
  ),
@@ -132,7 +133,7 @@ class ShareTest(datasets.GeneratorBasedBuilder):
132
  name=datasets.Split.TEST,
133
  # These kwargs will be passed to _generate_examples
134
  gen_kwargs={
135
- "filepath": os.path.join(data_dir, "data.xlsx"),
136
  "split": "test"
137
  },
138
  ),
@@ -158,15 +159,7 @@ class ShareTest(datasets.GeneratorBasedBuilder):
158
  # "option2": data["option2"],
159
  # "second_domain_answer": "" if split == "test" else data["second_domain_answer"],
160
  # }
161
- df = pd.read_excel(filepath)
162
- train_df = df.iloc[:700, :]
163
- validation_df = df.iloc[700:900, :]
164
- test_df = df.iloc[900:, :]
165
- if split == 'train':
166
- iteration = train_df
167
- elif split == 'validation':
168
- iteration = validation_df
169
- else:
170
- iteration = test_df
171
- for key in range(iteration.index.tolist()):
172
- yield key, iteration.loc[key, :]
 
40
  # "first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
41
  # "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
42
  # }
43
+ _URLS = 'D:/Jianbin/projects/hugging_face/datasets/test_script'
44
 
45
 
46
  # TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
47
+ class ScriptTest(datasets.GeneratorBasedBuilder):
48
  """TODO: Short description of my dataset."""
49
 
50
  VERSION = datasets.Version("1.0.0")
 
81
  "x8": datasets.Value("float"),
82
  "x9": datasets.Value("float"),
83
  "x10": datasets.Value("float"),
84
+ # 'shape': (1000, 11)
85
  # These are the features of your dataset like images, labels ...
86
  }
87
  )
 
111
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
112
  urls = _URLS
113
  data_dir = dl_manager.download_and_extract(urls)
114
+ # data_dir = urls
115
  return [
116
  datasets.SplitGenerator(
117
  name=datasets.Split.TRAIN,
118
  # These kwargs will be passed to _generate_examples
119
  gen_kwargs={
120
+ "filepath": os.path.join(data_dir, 'train.xlsx'),
121
  "split": "train",
122
  },
123
  ),
 
125
  name=datasets.Split.VALIDATION,
126
  # These kwargs will be passed to _generate_examples
127
  gen_kwargs={
128
+ "filepath": os.path.join(data_dir, 'validation.xlsx'),
129
  "split": "validation",
130
  },
131
  ),
 
133
  name=datasets.Split.TEST,
134
  # These kwargs will be passed to _generate_examples
135
  gen_kwargs={
136
+ "filepath": os.path.join(data_dir, 'test.xlsx'),
137
  "split": "test"
138
  },
139
  ),
 
159
  # "option2": data["option2"],
160
  # "second_domain_answer": "" if split == "test" else data["second_domain_answer"],
161
  # }
162
+ with open(filepath, 'rb') as f:
163
+ df = pd.read_excel(f)
164
+ for key in df.index.tolist():
165
+ yield key, dict(df.loc[key, :])
 
 
 
 
 
 
 
 
train.xlsx ADDED
Binary file (128 kB). View file
 
validation.xlsx ADDED
Binary file (45.6 kB). View file