🔌 Application Programming Interface#
galactic.io.data.text module
Class
TextDataReaderfor reading.txtfiles
- class TextDataReader#
Bases:
objectTXTdata 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 ... ''' >>> dataset = reader.read(io.StringIO(text)) >>> pprint({key: dict(data) for key, data in dataset.items()}) {'1': {'a': True, 'b': False, 'c': True, 'd': False, 'e': False}, '2': {'a': True, 'b': True, 'c': False, 'd': False, 'e': False}, '3': {'a': False, 'b': True, 'c': False, 'd': True, 'e': True}}
- extensions()#
Return an iterator over the supported file extensions.
- Returns:
An iterator over the supported file extensions
- Return type:
Iterator[str]
- read(data_file)#
Read a
TXTdata file.- Parameters:
data_file (
TextIO) – A readable text file- Returns:
The data set read from the file
- Return type:
DataSet
- Raises:
ValueError – If the format is incorrect