jina.types.arrays.mixins.io.csv module

class jina.types.arrays.mixins.io.csv.CsvIOMixin[source]

Bases: object

CSV IO helper.

can be applied to DA & DAM

save_embeddings_csv(file, **kwargs)[source]

Save embeddings to a CSV file

This function utilizes numpy.savetxt() internal.

Parameters
  • file (Union[str, TextIO]) – File or filename to which the data is saved.

  • kwargs – extra kwargs will be passed to numpy.savetxt().

Return type

None

save_csv(file, flatten_tags=True, exclude_fields=None, dialect='excel')[source]

Save array elements into a CSV file.

Parameters
  • file (Union[str, TextIO]) – File or filename to which the data is saved.

  • flatten_tags (bool) – if set, then all fields in Document.tags will be flattened into tag__fieldname and stored as separated columns. It is useful when tags contain a lot of information.

  • exclude_fields (Optional[Sequence[str]]) – if set, those fields wont show up in the output CSV

  • dialect (Union[str, Dialect]) – define a set of parameters specific to a particular CSV dialect. could be a string that represents predefined dialects in your system, or could be a csv.Dialect class that groups specific formatting parameters together.

Return type

None

classmethod load_csv(file, field_resolver=None)[source]

Load array elements from a binary file.

Parameters
  • file (Union[str, TextIO]) – File or filename to which the data is saved.

  • field_resolver (Optional[Dict[str, str]]) – a map from field names defined in JSON, dict to the field names defined in Document.

Return type

T

Returns

a DocumentArray object