idmd.data.uploader.FileUploader

class idmd.data.uploader.FileUploader(file_types=None, default_file=None)[source]

Bases: object

Handles file upload and data initialization.

Initializes the FileUploader with allowed file types and a default file.

Args:

file_types (list, optional): List of allowed file types for upload. Defaults to [“csv”, “xlsx”]. default_file (str, optional): Path to a default file to load if no file is uploaded. Defaults to None.

Methods

is_new_file

Checks if the uploaded file is new.

load_default_file

Loads the default file and initializes the dataset in the session state.

process_upload

Processes the uploaded file and initializes the dataset in the session state.

is_new_file(file, session_state)[source]

Checks if the uploaded file is new.

Return type:

bool

Args:

file: The uploaded file. session_state (dict): The session state to track the uploaded file.

Returns:

bool: True if the file is new, False otherwise.

load_default_file(session_state)[source]

Loads the default file and initializes the dataset in the session state.

Return type:

None

Args:

session_state (dict): The session state to store the dataset.

process_upload(file, session_state)[source]

Processes the uploaded file and initializes the dataset in the session state.

Return type:

None

Args:

file: The uploaded file. session_state (dict): The session state to store the dataset.