mawadalla commited on
Commit
54a09a9
1 Parent(s): 25685b5

Create script.py

Browse files
Files changed (1) hide show
  1. script.py +20 -0
script.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pyarrow.parquet as pq
2
+
3
+ class TatoebaLarge:
4
+ def __init__(self, file_path):
5
+ self.file_path = file_path
6
+ self.parquet_file = pq.ParquetFile(self.file_path)
7
+
8
+ def __iter__(self):
9
+ return self.parquet_file.iter_batches()
10
+
11
+ def __len__(self):
12
+ return self.parquet_file.metadata.num_rows
13
+
14
+ # Usage example
15
+ dataset = ParquetDataset("path/to/your/dataset.parquet")
16
+
17
+ for batch in dataset:
18
+ for example in batch.to_pydict():
19
+ # Do something with the example, e.g., preprocess the data
20
+ print(example)