albertvillanova HF staff commited on
Commit
447b2a5
1 Parent(s): 7b74c1d

Fix DuplicatedKeysError (#5)

Browse files

- Fix DuplicatedKeysError (5c0b806c9a1ece0437ad552b52109c8e205c941c)
- Change feature dtype to string (74a7e5df540b03d03f768caad4abec82e3d291d9)
- Update metadata (cfaa623373f055a7049877812ae74751c25aec87)

Files changed (2) hide show
  1. README.md +3 -3
  2. 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: int64
26
  splits:
27
  - name: train
28
- num_bytes: 25121264
29
  num_examples: 3140158
30
  download_size: 23678407
31
- dataset_size: 25121264
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 glob
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("int64")
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
- df = pd.read_csv(fname, names=["tweetID"])
135
- for id_, record in df.iterrows():
136
-
137
- tweetID = record["tweetID"]
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