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, 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 classified by top level shape markers: pandapower
("_class": "pandapowerNet"), egret (elements and system), GO Challenge
3 (network plus time_series_input/reliability), Surge JSON
(format: "surge-json"), powerio-json (buses plus network keys), and
PowerModels JSON (baseMVA, branch, gen, or gencost). JSON matching
distribution markers, ambiguous markers, or no known markers returns
Error::UnknownFormat. Pass from to force a
transmission format. 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.