Stem Docs

Descriptor Exporter

Descriptor Exporter

Toolkit for exporting descriptors to other formats.

Module Overview:

export_csv - Exports descriptors to a CSV
export_csv_file - Writes exported CSV output to a file

Deprecated since version 1.7.0.

stem.descriptor.export.export_csv(descriptors, included_fields=(), excluded_fields=(), header=True)[source]

Provides a newline separated CSV for one or more descriptors. If simply provided with descriptors then the CSV contains all of its attributes, labeled with a header row. Either 'included_fields' or 'excluded_fields' can be used for more granular control over its attributes and the order.

Parameters:
  • descriptors (Descriptor,list) -- either a Descriptor or list of descriptors to be exported
  • included_fields (list) -- attributes to include in the csv
  • excluded_fields (list) -- attributes to exclude from the csv
  • header (bool) -- if True then the first line will be a comma separated list of the attribute names (only supported in python 2.7 and higher)
Returns:

str of the CSV for the descriptors, one per line

Raises :

ValueError if descriptors contain more than one descriptor type

stem.descriptor.export.export_csv_file(output_file, descriptors, included_fields=(), excluded_fields=(), header=True)[source]

Similar to stem.descriptor.export.export_csv(), except that the CSV is written directly to a file.

Parameters:
  • output_file (file) -- file to be written to
  • descriptors (Descriptor,list) -- either a Descriptor or list of descriptors to be exported
  • included_fields (list) -- attributes to include in the csv
  • excluded_fields (list) -- attributes to exclude from the csv
  • header (bool) -- if True then the first line will be a comma separated list of the attribute names (only supported in python 2.7 and higher)
Returns:

str of the CSV for the descriptors, one per line

Raises :

ValueError if descriptors contain more than one descriptor type