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