pub fn parse_file(path: impl AsRef<Path>, from: Option<&str>) -> Result<Parsed>Expand description
Parse the case file at path, choosing the reader from from (the
target_format_from_name names plus pypsa-csv/pypsa, pwb, pslf,
and epc) 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/epc),
case insensitively (issue #97: .RAW is as common as .raw in the wild). A
.json file is sniffed four ways: pandapower ("_class": "pandapowerNet"),
egret (top level elements and system), the powerio-json snapshot (top
level buses), else PowerModels. Pass from to force one. PowerWorld .pwb
is a binary read only format with no retained source; PSLF .epc is text and
has a writer. 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.