🔌 Application Programming Interface#
Text Data reader.
- class TextDataReader#
Bases:
object
TXT Data reader.
Example
>>> from pprint import pprint >>> from galactic.io.data.text import TextDataReader >>> reader = TextDataReader() >>> import io >>> data = '''Observations: 1 2 3 ... Attributes: a b c d e ... 1: a c ... 2: a b ... 3: b d e ... ''' >>> individuals = reader.read(io.StringIO(data)) >>> pprint({key: sorted(list(value)) for key, value in individuals.items()}) {'1': ['a', 'c'], '2': ['a', 'b'], '3': ['b', 'd', 'e']}
- classmethod extensions()#
Get an iterator over the supported extensions.
- Returns:
An iterator over the supported extensions
- Return type:
Iterator[str]
- classmethod read(data_file)#
Read a
TXT
data file.- Parameters:
data_file (
TextIO
) – A readable text file.- Returns:
The data.
- Return type:
- Raises:
ValueError – If the format is incorrect.