eta_nexus.util.io_utils module
- eta_nexus.util.io_utils.json_import(path: Path) list[Any] | dict[str, Any][source]
Extend standard JSON import to allow ‘//’ comments in JSON files.
- Parameters:
path – Path to JSON file.
- Returns:
Parsed dictionary.
- eta_nexus.util.io_utils.toml_import(path: Path) dict[str, Any][source]
Import a TOML file and return the parsed dictionary.
- Parameters:
path – Path to TOML file.
- Returns:
Parsed dictionary.
- eta_nexus.util.io_utils.yaml_import(path: Path) dict[str, Any][source]
Import a YAML file and return the parsed dictionary.
- Parameters:
path – Path to YAML file.
- Returns:
Parsed dictionary.
- eta_nexus.util.io_utils.load_config(file: Path) dict[str, Any][source]
Load configuration from JSON, TOML, or YAML file.
The read file is expected to contain a dictionary of configuration options. When no file extension is provided, searches for files in the following priority order: 1. JSON (.json) 2. TOML (.toml) 3. YAML (.yml, .yaml)
- Parameters:
file – Path to the configuration file (with or without extension).
- Returns:
Dictionary of configuration options.
- eta_nexus.util.io_utils.replace_decimal_str(value: str | float, decimal: str = '.') str[source]
Replace the decimal separator in a numeric string.
- Parameters:
value – The numeric value to convert.
decimal – The decimal separator to use (e.g., ‘.’ or ‘,’).
- Returns:
String with replaced decimal separator.
- eta_nexus.util.io_utils.csv_export(path: Path, data: Mapping[str, Any] | Sequence[Mapping[str, Any] | Any] | pd.DataFrame, names: Sequence[str] | None = None, index: Sequence[int] | pd.DatetimeIndex | None = None, *, sep: str = ';', decimal: str = '.') None[source]
Export data to CSV file.
- Parameters:
path – Path to export CSV data.
data – Data to be saved (Mapping, DataFrame, or Sequence).
names – Field names used when data is a sequence without column names.
index – Optional sequence to set as the index.
sep – Separator to use between fields.
decimal – Decimal separator to use.