Datasets:

Tasks:
Other
Languages:
Arabic
Multilinguality:
monolingual
Size Categories:
1M<n<10M
Language Creators:
found
Annotations Creators:
no-annotation
Source Datasets:
original
ArXiv:
Tags:
data-mining
albertvillanova HF staff commited on
Commit
5c0b806
1 Parent(s): 7b74c1d

Fix DuplicatedKeysError

Browse files
Files changed (1) hide show
  1. ar_cov19.py +7 -11
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
 
@@ -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
 
 
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