🔌 Application Programming Interface

🔌 Application Programming Interface#

galactic.io.data.text module

Class


class TextDataReader#

Bases: object

TXT Data reader.

Example

>>> from pprint import pprint
>>> from galactic.io.data.text import TextDataReader
>>> reader = TextDataReader()
>>> import io
>>> text = '''Observations: 1 2 3
... Attributes: a b c d e
... 1: a c
... 2: a b
... 3: b d e
... '''
>>> data = reader.read(io.StringIO(text))
>>> pprint({key: sorted(value) for key, value in data.items()})
{'1': ['a', 'c'], '2': ['a', 'b'], '3': ['b', 'd', 'e']}
extensions()#

Get an iterator over the supported extensions.

Returns:

An iterator over the supported extensions

Return type:

Iterator[str]

read(data_file)#

Read a TXT data file.

Parameters:

data_file (TextIO) – A readable text file.

Returns:

The data.

Return type:

Data

Raises:

ValueError – If the format is incorrect.

register()#

Register an instance of a TXT data reader.

Return type:

None