DMelt:IO/7 YAML File Format
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.
DMelt supports writing and reading YAML files using the jhplot.io.HFileYAML 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 jhplot.io import * f=HFileYAML("test.yaml","w") data=[1,2,3,4] f.write("t0",data) f.close() # reading yaml file f=HFileYAML("test.yaml") print f.read("t0") f.close()
Let us consider how to store multi-dimensional data and histograms in the YAML files.
No access to this part. DataMelt members can view this part after login to member area.