🔌 Application Programming Interface

🔌 Application Programming Interface#

galactic.io.data.csv module

Class


class CSVDataReader#

Bases: object

CSV data reader.

Example

>>> from pprint import pprint
>>> from galactic.io.data.csv import CSVDataReader
>>> reader = CSVDataReader()
>>> import io
>>> text = '''age,height
... 46,202
... 36,183
... 204,230
... 36,180
... 23,150
... 23,172
... '''
>>> dataset = reader.read(io.StringIO(text))
>>> pprint(dataset)
[frozendict.frozendict({'age': '46', 'height': '202'}),
 frozendict.frozendict({'age': '36', 'height': '183'}),
 frozendict.frozendict({'age': '204', 'height': '230'}),
 frozendict.frozendict({'age': '36', 'height': '180'}),
 frozendict.frozendict({'age': '23', 'height': '150'}),
 frozendict.frozendict({'age': '23', 'height': '172'})]
extensions()#

Return an iterator over the supported file extensions.

Returns:

An iterator over the supported extensions

Return type:

Iterator[str]

read(data_file)#

Read a CSV data file.

Parameters:

data_file (TextIO) – A readable text file

Returns:

The dataset read from the file

Return type:

DataSet

register()#

Register an instance of a CSV data reader.

Return type:

None