The diffpy.utils.parsers
module allows users to easily and robustly load file data into a Python project.
loaddata.loadData()
: Find and load a data table/block from a text file. This seems to work for most datafiles including those generated by diffpy programs. Running onlynumpy.loadtxt
will result in errors for most these files as there is often excess data or parameters stored above the data block. Users can instead choose to load all the parameters of the form<param_name> = <param_value>
into a dictionary with this function by setting theheader
parameter toTrue
.The program identifies data blocks as the first matrix block with a constant number of columns. A user can tune the minimum number of rows this matrix block must have.
serialization.deserialize_data()
: Load data from a serial file format into a Python dictionary. Currently, the only supported serial format is.json
.serialization.serialize_data()
: Serialize the data generated byloadData()
into a serial file format. Currently, the only supported serial format is.json
.
For a more in-depth tutorial for how to use these parser utilities, click :ref:`here <Parsers Example>`.