backend.utils.file_handlers

Contains utility functions for handling file uploads.

Functions

process_xes_file(→ pandas.DataFrame)

Processes XES file content and converts it to a DataFrame.

process_csv_file(→ pandas.DataFrame)

Processes CSV file content and converts it to a Pandas DataFrame.

process_file(→ pandas.DataFrame)

Processes file content and converts it to a pandas DataFrame.

Module Contents

backend.utils.file_handlers.process_xes_file(file_content: bytes) pandas.DataFrame

Processes XES file content and converts it to a DataFrame.

This function is needed, as the transferred file via the API is in bytes, and pm4py does not support reading from bytes directly. Therefore, we create a temporary file to store the uploaded content and then read it using pm4py.

Parameters:

file_content – Binary content of the XES file.

Returns:

A pandas DataFrame containing the event log.

Raises:

ValueError – If the file cannot be processed.

backend.utils.file_handlers.process_csv_file(file_content: bytes) pandas.DataFrame

Processes CSV file content and converts it to a Pandas DataFrame.

Parameters:

file_content – The binary content of the CSV file.

Returns:

A pandas DataFrame containing the CSV data.

Raises:

ValueError – If the file cannot be processed.

backend.utils.file_handlers.process_file(file_content: bytes, file_extension: str) pandas.DataFrame

Processes file content and converts it to a pandas DataFrame.

This function acts as a dispatcher that directs the file processing to the appropriate handler based on the file extension.

Parameters:
  • file_content – Binary content of the file.

  • file_extension – The file extension (e.g., “.csv” or “.xes”).

Returns:

A pandas DataFrame containing the processed data.

Raises:

ValueError – If the file cannot be processed or if the file type is unsupported.