utils.io_utils
utils.io_utils
IO Utils - ParquetWriter and Convenience Wrappers
Expose ParquetWriter and convenience functions for reading/writing tables.
Functions
| Name | Description |
|---|---|
| get_writer | Get ParquetWriter instance. |
| read_table | Read table from parquet storage. |
| save_viz_data_json | Save visualization data as tidy JSON next to a PNG. |
| write_table | Write DataFrame to parquet storage. |
get_writer
utils.io_utils.get_writer(base_dir: str | Path | None = None)Get ParquetWriter instance.
Args: base_dir: Base data directory (uses default from config if None)
read_table
utils.io_utils.read_table(table: str, base_dir: str | Path | None = None)Read table from parquet storage.
Args: table: Table name (e.g., “gold.facilities_production_annual”) base_dir: Base data directory (uses default from config if None)
save_viz_data_json
utils.io_utils.save_viz_data_json(
df: pd.DataFrame,
output_path: Path,
orient: str = 'records',
)Save visualization data as tidy JSON next to a PNG.
Args: df: DataFrame containing the data actually plotted output_path: Path to the PNG file (JSON will reuse the same stem) orient: pandas to_json orientation (“records” is best for Observable)
Returns: Path to the JSON file
write_table
utils.io_utils.write_table(
df: pd.DataFrame,
table: str,
base_dir: str | Path | None = None,
)Write DataFrame to parquet storage.
Args: df: DataFrame to write table: Table name (e.g., “gold.facilities_production_annual”) base_dir: Base data directory (uses default from config if None)