-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_loader.py
More file actions
39 lines (29 loc) 路 1.05 KB
/
Copy pathdata_loader.py
File metadata and controls
39 lines (29 loc) 路 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pandas as pd
import os
from config import logger
# Directory where Parquet files are stored
PARQUET_DIR = 'data/'
import os
from config import logger
# Directory where Parquet files are stored
PARQUET_DIR = 'data/'
def get_parquet_files():
"""List all Parquet files in the data directory."""
try:
if not os.path.isdir(PARQUET_DIR):
raise FileNotFoundError(f"Directory not found: {PARQUET_DIR}")
files = [f for f in os.listdir(PARQUET_DIR) if f.endswith('.parquet')]
logger.info(f"Found Parquet files: {files}")
return files
except Exception as e:
logger.error(f"Error listing Parquet files: {e}")
raise
def lazy_load_dataset(file_name):
"""Create a lazy loader for the specified Parquet file."""
file_path = os.path.join(PARQUET_DIR, file_name)
logger.info(f"Preparing to load dataset from {file_path}")
# Return a lazy loader function
def load():
logger.info(f"Loading dataset from {file_path}")
return pd.read_parquet(file_path)
return load