SDF.file_io: Read and write files¶
The submodule SDF.file_io
contains the functionality for reading files to SDF objects and writing those to
files.
Read¶
To read files to SDF objects, there are multiple functions, one per implemented input format:
load_from_sdf
(filename): read .sdf filesload_from_jpk
(filename): read .jpk filesload_from_mfp
(filename): read .ibw files (from MFP-3D instruments)load_from_lsm
(filename): read .lsm filesload_from_oif
(filename): read .oif filesload_from_oib
(filename): read .oib files
They all expect a filename as argument and return an SDF Object (usually a Workspace).
Write¶
SDF Objects (Workspace and Dataset types) can be written to files by calling
write_sdf
(sdf_object, filename).
This calls XMLWritable.to_xml_element
() and serializes
that XML Element to a text file. This could also be done by any other XML library.
Example¶
from SDF.file_io import load_from_lsm, write_sdf
sdf = load_from_lsm("my-data.lsm")
write_sdf(sdf, "my-data.sdf")