pyface.data_view.data_formats module¶
- pyface.data_view.data_formats.to_json(data, default=None)[source]¶
Serialize an object to a JSON bytestring.
- Parameters
data (Any) – The data to be serialized.
default (Callable or None) – Callable that takes a Python object and returns a JSON-serializable data structure.
- Returns
raw_data – The serialized data as a bytestring.
- Return type
- pyface.data_view.data_formats.from_json(raw_data, object_hook=None)[source]¶
Deserialize a JSON bytestring.
- Parameters
raw_data (bytes) – The serialized JSON data as a byte string.
object_hook (Callable) – Callable that takes a dictionary and returns an corresponding Python object.
- Returns
data – The data extracted.
- Return type
Any
- pyface.data_view.data_formats.standard_text_format = DataFormat(mimetype='text/plain', serialize=functools.partial(<built-in function encode>, encoding='utf-8'), deserialize=functools.partial(<built-in function decode>, encoding='utf-8'))¶
The text/plain format with utf-8 encoding.
- pyface.data_view.data_formats.html_format = DataFormat(mimetype='text/html', serialize=functools.partial(<built-in function encode>, encoding='utf-8'), deserialize=functools.partial(<built-in function decode>, encoding='utf-8'))¶
The text/html format with utf-8 encoding.
- pyface.data_view.data_formats.json_format = DataFormat(mimetype='application/json', serialize=<function to_json>, deserialize=<function from_json>)¶
A generic JSON format.
- pyface.data_view.data_formats.to_csv_row(data, delimiter=',', encoding='utf-8', **kwargs)[source]¶
Serialize a list to a single-row CSV bytestring.
- Parameters
- Returns
raw_data – The serialized data as a bytestring.
- Return type
- pyface.data_view.data_formats.from_csv_row(raw_data, delimiter=',', encoding='utf-8', **kwargs)[source]¶
Deserialize the first row of a CSV bytestring as a list.
Any rows beyond the first are ignored.
- pyface.data_view.data_formats.to_csv_column(data, delimiter=',', encoding='utf-8', **kwargs)[source]¶
Serialize a list to a single-column CSV bytestring.
- Parameters
- Returns
raw_data – The serialized data as a bytestring.
- Return type
- pyface.data_view.data_formats.from_csv_column(raw_data, delimiter=',', encoding='utf-8', **kwargs)[source]¶
Deserialize the first column of a CSV bytestring as a list.
Any columns beyond the first are ignored.
- pyface.data_view.data_formats.to_csv(data, delimiter=',', encoding='utf-8', **kwargs)[source]¶
Serialize a list of lists to a CSV bytestring.
- Parameters
- Returns
raw_data – The serialized data as a bytestring.
- Return type
- pyface.data_view.data_formats.from_csv(raw_data, delimiter=',', encoding='utf-8', **kwargs)[source]¶
Deserialize a CSV bytestring.