hyloa.data.io module
Code to handle data input and output, i.e. loading and saving data
- hyloa.data.io.clean_column_name(name, filename)[source]
Clean the column name by removing the filename prefix if it exists.
- Parameters:
name (string) – column name to clean
filename (string) – filename to remove from the column name if it is a prefix
- Returns:
cleaned_name – cleaned column name without the filename prefix
- Return type:
string
- hyloa.data.io.detect_header_length(file_path, sep='\t')[source]
Function to compute the length of the header and therefore, the number of rows to exclude from the dataframe to obtain a dataframe that has for each column only the data of interest.
- Parameters:
file_path (string) – path of the file to read
sep (string) – separetor, optional, default a tabulation
- Returns:
data_start – number of the not empty lines of the file’s header
- Return type:
int
- hyloa.data.io.duplicate_file(parent_widget=None)[source]
Duplicates a selected file by creating a copy named <original>_copy.ext. Opens a file dialog to select a file and creates a duplicate of it with ‘_copy’ appended to the name.
Parameters:
- parent_widget(QWidget, optional)
The parent widget for dialogs. Defaults to None.
- hyloa.data.io.load_files(app_instance)[source]
Function to upload a file chosen by the user. If the file has an header, this will be preserved when the data is saved to a new file.
- Parameters:
app_instance (instance of MainApp from main_window.py)
- hyloa.data.io.save_header(app_instance, header_df, df, file_path)[source]
Save the header in the final text file, to provide compatibility in case you want to reopen it for further analysis.
- Parameters:
app_instance (MainApp object) – instance of MainApp from main_window.py
header_df (pandas dataframe) – dataframe containing the header of the data file
df (pandas dataframe) – dataframe containing only the header of the data file
file_path (string) – path of the file to save
- hyloa.data.io.save_modified_data(app_instance, parent_widget)[source]
Allows you to choose the file and data to save, with the related headers.
- Parameters:
app_instance (MainApp object) – instance of MainApp from main_window.py
parent_widget (QWidget) – parent widget for the dialog
- hyloa.data.io.save_to_file(df_idx, app_instance, parent_widget=None)[source]
Save the selected data to a new text file. If fewer columns than the 8 available are loaded, columns of zeros will be added to maintain compatibility.
- Parameters:
df_idx (int) – index of the selected dataframe
app_instance (MainApp object) – instance of MainApp from main_window.py
save_window (Toplevel object) – window to close after saving the data