docarray.array.mixins.io.common module#
- class docarray.array.mixins.io.common.CommonIOMixin[source]#
Bases:
object
The common IO helper function for arrays.
- save(file, file_format='binary', encoding='utf-8')[source]#
Save array elements into a JSON, a binary file or a CSV file.
- Parameters:
file (
Union
[str
,TextIO
,BinaryIO
]) – File or filename to which the data is saved.file_format (
str
) – json or binary or csv. JSON and CSV files are human-readable, but binary format gives much smaller size and faster save/load speed. Note that, CSV file has very limited compatability, complex DocumentArray with nested structure can not be restored from a CSV file.encoding (
str
) – encoding used to save data into a file (it only applies to JSON and CSV format). By default,utf-8
is used.
- Return type:
None
- classmethod load(file, file_format='binary', encoding='utf-8', **kwargs)[source]#
Load array elements from a JSON or a binary file, or a CSV file.
- Parameters:
file (
Union
[str
,TextIO
,BinaryIO
]) – File or filename to which the data is saved.file_format (
str
) – json or binary or csv. JSON and CSV files are human-readable, but binary format gives much smaller size and faster save/load speed. CSV file has very limited compatability, complex DocumentArray with nested structure can not be restored from a CSV file.encoding (
str
) – encoding used to load data from a file (it only applies to JSON and CSV format). By default,utf-8
is used.
- Return type:
T
- Returns:
the loaded DocumentArray object