corrinout module

class corrinout.CorrInOut[source]

Bases: object

Class to import and export to/from excel/csv and from/to a db.

error() str[source]

Get last error from library.

Parameters:

needed (None)

Returns:

The error message, if any

Return type:

str

export2csv(data, delimiter=';', include=False) NamedTemporaryFile[source]

Export dict data structure to a CSV-file.

Parameters:
  • data (dict) – The dict data structure to export.

  • delimiter (str) – Sets the delimiter to use when writing data structure to file. One character only. Defaults to “;” or semicolon.

  • include (bool) – Specify if we are to include and export fields that are not public. These fields are defined in the CorrDB-class library.

Returns:

The NamedTemporaryFile-instance containing the CSV-data.

Return type:

NamedTemporaryFile

export2excel(data, include=False) NamedTemporaryFile[source]

Export dict data structure to a Excel-file.

Parameters:
  • data (dict) – The dict data structure to export.

  • include (bool) – Specify if we are to include and export fields that are not public. These fields are defined in the CorrDB-class library.

Returns:

The NamedTemporaryFile-instance containing the Excel-data.

Return type:

NamedTemporaryFile

import_csv_file(fileobject) dict[source]

Import CSV-file and return as a dict-instance

Parameters:

fileobject (NamedTemporaryFile) – The file to import

Returns:

The csv-file as a dict-structured object or None upon failure.

Read failure message from the error()-method if applicable.

Return type:

dict

import_excel_file(fileobject) dict[source]

Import Excel-file and return as a dict-instance

Parameters:

fileobject (NamedTemporaryFile) – The file to import

Returns:

The Excel-file as a dict-structured object or None upon failure.

Read failure message from the error()-method if applicable.

Return type:

dict