algebraixlib.io.csv module

Import clans from and export them to CSV data.

algebraixlib.io.csv.export_csv(absolute_clan: 'PP(A x A)', file_or_path, column_order=None, sort_key=None)[source]

This function takes an absolute, left regular clan and produces a CSV file, where the left components are in the header line and the rows are the individual relations.

Parameters:
  • absolute_clan – A algebraixlib.mathobjects.set.Set. It must be an absolute and left-regular clan.
  • file_or_path – Either a file path (in this case the CSV data is written to a file at this location) or a file object (in this case the CSV data is written to its .write() function).
  • column_order – The optional left set to be exported in the specified order.
  • sort_key – The optional key to be provided to sorted (sorted not called if None).
Returns:

True if the CSV export succeeded.

algebraixlib.io.csv.import_csv(csv_file_or_filepath, types=None, skip_rows=0, index_column=None, has_dup_rows=False) → 'PP( A x M )'[source]

Import the file csv_file_or_filepath as CSV data and return a clan.

Parameters:
  • csv_file_or_filepath – The file path or file object (for example StringIO buffer) to import.
  • types – An optional dictionary of type conversions. The keys are the column names; the values are functors (or types) that receive the string from the CSV cell and return the value to be imported. Example: {'foo': int, 'bar': float}.
  • skip_rows – An optional number of lines to skip (default 0). Some CSV files have a preamble that can be skipped with this option.
  • index_column – An optional name for an index column. (No index column is created if this argument is not specified.) The index starts with 0.
  • has_dup_rows – An optional flag to return a multiclan instead of a clan. This option will count the duplicate rows of relations and store the quantities in a multiset. It can not be used in conjunction with the index_column option.