🔌 Application Programming Interface

🔌 Application Programming Interface#

CSV Data reader.

class CSVDataReader#

Bases: object

CSV Data reader.

Example

>>> from pprint import pprint
>>> from galactic.io.data.csv import CSVDataReader
>>> reader = CSVDataReader()
>>> import io
>>> data = '''age,height
... 46,202
... 36,183
... 204,230
... 36,180
... 23,150
... 23,172
... '''
>>> data = reader.read(io.StringIO(data))
>>> pprint(data)
{'0': {'age': '46', 'height': '202'},
 '1': {'age': '36', 'height': '183'},
 '2': {'age': '204', 'height': '230'},
 '3': {'age': '36', 'height': '180'},
 '4': {'age': '23', 'height': '150'},
 '5': {'age': '23', 'height': '172'}}
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 CSV data file.

Parameters:

data_file (TextIO) – A readable text file.

Returns:

The data.

Return type:

Mapping[str, object]

register()#

Register an instance of a CSV data reader.

Return type:

None