TEXT data reader
TEXT data reader reads files whose extension is .txt
.
[1]:
import tempfile
from pprint import pprint
from galactic.io.data.core import PopulationFactory
data = """\
Observations: 1 2 3 4
Attributes: a b c d e
1: a c
2: a b
3: b d e
4: c e
"""
with tempfile.NamedTemporaryFile(mode="w+t", suffix=".txt") as file:
file.write(data)
file.seek(0)
population = PopulationFactory.create(file)
pprint({key: sorted(value) for key, value in population.items()}, width=75)
{'1': ['a', 'c'], '2': ['a', 'b'], '3': ['b', 'd', 'e'], '4': ['c', 'e']}