minskiter commited on
Commit
4699640
1 Parent(s): 1e2c321

fix(weibo.py): fix online dataviewer error

Browse files
Files changed (1) hide show
  1. weibo.py +9 -7
weibo.py CHANGED
@@ -106,13 +106,15 @@ class WeiboNamedEntities(datasets.GeneratorBasedBuilder):
106
  ]
107
 
108
  def _generate_examples(self, filepath):
109
- file = pq.ParquetFile(filepath)
110
- _id = -1
111
- for i in file.iter_batches(batch_size=64):
112
- rows = i.to_pylist()
113
- for row in rows:
114
- _id+=1
115
- yield _id, row
 
 
116
 
117
 
118
 
 
106
  ]
107
 
108
  def _generate_examples(self, filepath):
109
+ # fix: https://discuss.huggingface.co/t/dataset-preview-error-with-a-dataset-script-and-parquet-files/43160
110
+ with open(filepath, "rb") as f:
111
+ with pq.ParquetFile(f) as file:
112
+ _id = -1
113
+ for i in file.iter_batches(batch_size=64):
114
+ rows = i.to_pylist()
115
+ for row in rows:
116
+ _id+=1
117
+ yield _id, row
118
 
119
 
120