pub fn parse_file(
path: impl AsRef<Path>,
from: Option<&str>,
) -> Result<Parsed, Error>Expand description
Parse the case file at path, choosing the reader from from (the
target_format_from_name names plus pypsa-csv/pypsa and pwb) or,
when None, from the path: a directory containing network.csv parses as
a PyPSA CSV folder (any other directory fails: Error::UnknownFormat
when its name maps to no extension, the I/O error otherwise), and a
file maps by extension (m/json/raw/aux/pwb), case-insensitively
(issue #97: .RAW is as common as .raw in the wild). A .json file is
sniffed three ways: pandapower ("_class": "pandapowerNet"), egret (top
level elements and system), else PowerModels. Pass from to force one.
.pwb binaries are read only and carry no retained source. Returns
Parsed: the network plus the reader’s fidelity warnings.
The one path-based parser the CLI and the Python/C/Julia bindings share (each
exposes the same parse_file(path, from) shape), so adding a source format is
one edit here, not one per binding. For in-memory text use parse_str.
§Errors
Error::UnknownFormat if from is unrecognized or the extension can’t be
mapped; Error::Io if the file can’t be read; the reader’s own Error
on malformed input.