🔌 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
... '''
>>> data = reader.read(io.StringIO(text))
>>> pprint(data)
[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()#

Get an iterator over the supported 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 data.

Return type:

Data

register()#

Register an instance of a CSV data reader.

Return type:

None