Fix DuplicatedKeysError
#5
by
albertvillanova
HF staff
- opened
- README.md +3 -3
- ar_cov19.py +8 -12
README.md
CHANGED
@@ -22,13 +22,13 @@ dataset_info:
|
|
22 |
config_name: ar_cov19
|
23 |
features:
|
24 |
- name: tweetID
|
25 |
-
dtype:
|
26 |
splits:
|
27 |
- name: train
|
28 |
-
num_bytes:
|
29 |
num_examples: 3140158
|
30 |
download_size: 23678407
|
31 |
-
dataset_size:
|
32 |
---
|
33 |
|
34 |
# Dataset Card for ArCOV19
|
|
|
22 |
config_name: ar_cov19
|
23 |
features:
|
24 |
- name: tweetID
|
25 |
+
dtype: string
|
26 |
splits:
|
27 |
- name: train
|
28 |
+
num_bytes: 72223634
|
29 |
num_examples: 3140158
|
30 |
download_size: 23678407
|
31 |
+
dataset_size: 72223634
|
32 |
---
|
33 |
|
34 |
# Dataset Card for ArCOV19
|
ar_cov19.py
CHANGED
@@ -15,10 +15,7 @@
|
|
15 |
"""TODO: Add a description here."""
|
16 |
|
17 |
|
18 |
-
import
|
19 |
-
import os
|
20 |
-
|
21 |
-
import pandas as pd
|
22 |
|
23 |
import datasets
|
24 |
|
@@ -92,7 +89,7 @@ class ArCov19(datasets.GeneratorBasedBuilder):
|
|
92 |
|
93 |
features = {}
|
94 |
|
95 |
-
features["tweetID"] = datasets.Value("
|
96 |
|
97 |
return datasets.DatasetInfo(
|
98 |
# This is the description that will appear on the datasets page.
|
@@ -129,11 +126,10 @@ class ArCov19(datasets.GeneratorBasedBuilder):
|
|
129 |
# TODO: This method will receive as arguments the `gen_kwargs` defined in the previous `_split_generators` method.
|
130 |
# It is in charge of opening the given file and yielding (key, example) tuples from the dataset
|
131 |
# The key is not important, it's more here for legacy reason (legacy from tfds)
|
|
|
132 |
for fname in data_files:
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
yield str(id_), {"tweetID": tweetID}
|
|
|
15 |
"""TODO: Add a description here."""
|
16 |
|
17 |
|
18 |
+
import csv
|
|
|
|
|
|
|
19 |
|
20 |
import datasets
|
21 |
|
|
|
89 |
|
90 |
features = {}
|
91 |
|
92 |
+
features["tweetID"] = datasets.Value("string")
|
93 |
|
94 |
return datasets.DatasetInfo(
|
95 |
# This is the description that will appear on the datasets page.
|
|
|
126 |
# TODO: This method will receive as arguments the `gen_kwargs` defined in the previous `_split_generators` method.
|
127 |
# It is in charge of opening the given file and yielding (key, example) tuples from the dataset
|
128 |
# The key is not important, it's more here for legacy reason (legacy from tfds)
|
129 |
+
id_ = 0
|
130 |
for fname in data_files:
|
131 |
+
with open(fname, newline='') as csvfile:
|
132 |
+
reader = csv.DictReader(csvfile, fieldnames=["tweetID"])
|
133 |
+
for row in reader:
|
134 |
+
yield id_, row
|
135 |
+
id_ += 1
|
|
|
|