Create script.py
Browse files
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)
|