You're reading an old version of this documentation. For up-to-date information, please have a look at v0.11.

aspecd.infofile module

Handle Infofile files containing metadata for (experimental) data.

The Infofile format is a special format dedicated to storing metadata accompanying experimental data. Further information on the format including the full specification can be found in the following publication:

  • Bernd Paulus, Till Biskup: Towards more reproducible and FAIRer research data: documenting provenance during data acquisition using the Infofile format. Digital Discovery 2:234–244, 2023, doi:10.1039/D2DD00131D

For actual Infofile example files, see the git repository available at GitHub:

Development of the templates for specific methods will always be closely connected to the respective data model, e.g. in context of the trepr and cwepr Python packages.

This module reads and parses files complying with the infofile file format. At the same time, it contains the reference implementation of the parser for the Infofile format.

Note

For own purposes, you may prefer using YAML files to store metadata that are collected in parallel to recording data over the infofile format. For more information on this format and it specification, consult its webpage: https://yaml.org/.

However, you may still be interested in the discussion of the Infofile format and its advantages and disadvantages compared to formats such as YAML and JSON. For this, you are kindly referred to the reference given above, describing and discussing the Infofile format in more detail.

As the lead developer of the ASpecD framework originally invented the infofile format for own purposes, there are quite some datasets floating around in his lab using this format for the corresponding metadata. Hence the need of a module handling this particular file type.

To map the information contained in the info file to datasets, have a look at the aspecd.metadata.MetadataMapper class. You can define rather elaborate mapping tables, allowing to rename keys as well as to combine items of a dictionary.

class aspecd.infofile.Infofile(filename=None)

Bases: object

Reading metadata contained in info files.

parameters

Structure containing parameters read from info file.

Type:

collections.OrderedDict

filename

Name of the info file read

Type:

str

infofile_info

Information about the infofile, such as kind, version, and date.

Helpful for mapping metadata contained in an infofile to datasets.

Type:

dict

Parameters:

filename (str) – Name of the info file to read

Raises:

Changed in version 0.6.3: Comment gets converted into a single string.

parse()

Parse info file.

Raises:
aspecd.infofile.parse(filename='')

Parse info file.

Conventional interface provided for convenience that gives easy access to the metadata stored in an infofile. For full use of the capabilities of the Infofile class, use its object-oriented interface.

Warning

This will only return the metadata read from the info file, not the version information that is read and parsed as well. To obtain this version information, e.g., for mapping of metadata onto other structures, you should use the object-oriented interface of the Infofile class.

Parameters:

filename (str) – Name of the info file to parse

Returns:

metadata – Dictionary with metadata read from info file

Return type:

dict