DMelt:IO/7 YAML File Format

From HandWiki
Revision as of 11:16, 14 February 2021 by imported>Jworkorg
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Limitted access. First login to DataMelt if you are a full DataMelt member. Then login to HandWiki as a user.

YAML file format

DataMelt includes library to handle YAML data format. The YAML format is described in YAML web page. The included Java implementation is based on SnakeYAML. The Java API can be found in SnakeYAML API SnakeYAML API.

DMelt supports writing and reading YAML files using the class. It keeps data in the form key-values. Most DMelt arrays and histograms are supported,

The YAML files can hold many Java and Python object in a form of simple text files. This is useful for exchange of data between different programming languages. The files are typically smaller then similar XML files since no tags is used. This feature makes YAML files attractive to keep numeric data.

For example, Java ArrayList or Python list will be written to the text file exactly it should look:


You can also write lists, maps (dictionaries) to external files in arbitrary order. Then you can read such text files back, creating Java lists (Python lists) on the fly. Also, objects such as P1D, histograms (H1D) are supported.

This is an example of parsing YAML string messages:

This is an example:

from import *
# reading  yaml file

Let us consider how to store multi-dimensional data and histograms in the YAML files.