jordyvl commited on
Commit
79590ff
·
1 Parent(s): 1b52332

read from bytes

Browse files
Files changed (1) hide show
  1. unit-test_PDFfolder.py +8 -9
unit-test_PDFfolder.py CHANGED
@@ -102,23 +102,22 @@ class PdfFolder(datasets.GeneratorBasedBuilder):
102
 
103
  #archive_path = archive_iterator.args[0]
104
 
105
- extensions = {".pdf", ".PDF"}
106
  for file_path, file_obj in archive_iterator:
107
 
108
- import pdb; pdb.set_trace() # breakpoint 401560d4 //
 
109
 
110
  folder, labelset, label, filename = file_path.split("/")
111
  if labelset != supposed_labelset:
112
  continue
113
-
114
- if filename.split(".")[-1] in extensions:
115
- import pdb; pdb.set_trace() # breakpoint 75999c30 //
116
-
117
- images = pdf2image.convert_from_bytes(file_obj.read())
118
 
119
- simple = {"path": file_path, "bytes": file_obj.read()}
120
 
121
- yield file_path, {"file": images, "labels": label}
122
 
123
  #labels = self.info.features["labels"]
124
  #labels.encode_example(path.parent.name.lower())
 
102
 
103
  #archive_path = archive_iterator.args[0]
104
 
105
+ extensions = {"pdf", "PDF"}
106
  for file_path, file_obj in archive_iterator:
107
 
108
+ if file_path.split(".")[-1] not in extensions: #metadata.jsonlines
109
+ continue
110
 
111
  folder, labelset, label, filename = file_path.split("/")
112
  if labelset != supposed_labelset:
113
  continue
114
+ import pdb; pdb.set_trace() # breakpoint d40ef36a //
115
+
116
+ images = pdf2image.convert_from_bytes(file_obj.read())
 
 
117
 
118
+ simple = {"path": file_path, "bytes": file_obj.read(), "labels": label}
119
 
120
+ yield file_path, {"file": images, "labels": label}
121
 
122
  #labels = self.info.features["labels"]
123
  #labels.encode_example(path.parent.name.lower())