YAML data reader
YAML data reader reads files whose extension is .yaml
or .yml
.
[1]:
import tempfile
from pprint import pprint
from galactic.io.data.core import PopulationFactory
data = """\
# This is a YAML document.
- name: Galois
firstname: Évariste
- name: Wille
firstname: Rudolf
"""
with tempfile.NamedTemporaryFile(mode="w+t", suffix=".yaml") as file:
file.write(data)
file.seek(0)
population = PopulationFactory.create(file)
pprint(dict(population.items()))
{'0': {'firstname': 'Évariste', 'name': 'Galois'},
'1': {'firstname': 'Rudolf', 'name': 'Wille'}}