tomrb commited on
Commit
9d962b5
·
1 Parent(s): e0b55da
Files changed (1) hide show
  1. minipileoflaw.py +5 -4
minipileoflaw.py CHANGED
@@ -4,6 +4,7 @@
4
  import gzip
5
  import json
6
  import csv
 
7
 
8
  import datasets
9
  try:
@@ -98,10 +99,10 @@ class MiniPileOfLaw(datasets.GeneratorBasedBuilder):
98
  for filepath in filepaths:
99
  logger.info("Generating examples from = %s", filepath)
100
  try:
101
- with open(filepath, "r", encoding="utf-8") as file:
102
- reader = csv.DictReader(file)
103
- for row in reader:
104
- yield id_, {
105
  "text": row.get("text", ""),
106
  "created_timestamp": row.get("created_timestamp", ""),
107
  "downloaded_timestamp": row.get("downloaded_timestamp", ""),
 
4
  import gzip
5
  import json
6
  import csv
7
+ import pandas as pd
8
 
9
  import datasets
10
  try:
 
99
  for filepath in filepaths:
100
  logger.info("Generating examples from = %s", filepath)
101
  try:
102
+
103
+ dataframe = pd.read_csv(filepath, delimiter=",")
104
+ for id_, row in dataframe.iterrows():
105
+ yield id_, {
106
  "text": row.get("text", ""),
107
  "created_timestamp": row.get("created_timestamp", ""),
108
  "downloaded_timestamp": row.get("downloaded_timestamp", ""),