The managecsv modul¶
gamslib.objectcsv.manage_csv
¶
Functions to collect and update object and datastream CSV files for GAMS projects.
Provides utilities to aggregate metadata from all object folders into central CSV/XLSX files, and to distribute updated metadata back to individual object folders.
collect_csv_data
¶
Collect metadata from all object folders below object_root_dir and save to combined CSV files.
| PARAMETER | DESCRIPTION |
|---|---|
object_root_dir
|
Root directory containing all object folders.
TYPE:
|
object_csv_path
|
Path to save combined object metadata CSV. Defaults to 'object.csv' in CWD.
TYPE:
|
datastream_csv_path
|
Path to save combined datastream metadata CSV. Defaults to 'datastreams.csv' in CWD.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ObjectCollection
|
Collection containing all object and datastream metadata.
TYPE:
|
Notes
- Reads all object.csv and datastreams.csv files below object_root_dir.
- Saves aggregated metadata to the specified CSV files.
split_from_xlsx
¶
Update object folder CSV metadata from a combined XLSX file.
| PARAMETER | DESCRIPTION |
|---|---|
object_root_dir
|
Root directory containing all object folders.
TYPE:
|
xlsx_file
|
Path to the XLSX file. Defaults to 'all_objects.xlsx' in CWD.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int]
|
tuple[int, int]: Number of updated objects and number of updated datastreams. |
| RAISES | DESCRIPTION |
|---|---|
UserWarning
|
If an object directory does not exist. |
Notes
- Reads the XLSX file created by collect_csv_data().
- Updates object.csv and datastreams.csv files in all object folders below object_root_dir.
split_from_csv
¶
Update object folder CSV metadata from combined CSV files.
| PARAMETER | DESCRIPTION |
|---|---|
object_root_dir
|
Root directory containing all object folders.
TYPE:
|
object_csv_path
|
Path to combined object metadata CSV. Defaults to 'object.csv' in CWD.
TYPE:
|
ds_csv_path
|
Path to combined datastream metadata CSV. Defaults to 'datastreams.csv' in CWD.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int]
|
tuple[int, int]: Number of updated objects and number of updated datastreams. |
| RAISES | DESCRIPTION |
|---|---|
UserWarning
|
If an object directory does not exist. |
Notes
- Reads the CSV files created by collect_csv_data().
- Updates object.csv and datastreams.csv files in all object folders below object_root_dir.