Data Loader
The DataLoader class handles the import and validation of user-provided data files before they are passed to the application’s visualization and fitting components.
Responsibilities
- Open files using a dialog or programmatic input
- Read and validate
.csvcontent - Ensure required columns (
X,Y) are present - Reject malformed or incomplete data
- Return a clean
pandas.DataFramefor downstream use
Supported Formats
.csv(standard)- Custom loaders can be added (see Custom Loader Guide)
Main Methods
load_data(file_name=None)
- Opens a file dialog (if
file_nameis not passed) - Dispatches to the appropriate read method
- On success, returns a validated
DataFrameand the file path
read_csv(file_path)
- Uses
pandas.read_csv()to load file - Validates presence of
XandYcolumns - Checks for NaNs or non-numeric values
show_error_message(message)
- Uses
QMessageBoxto inform the user of errors (e.g., missing columns or invalid format)
Typical Integration
df, file_path = data_loader.load_data()
if df is not None:
tab.load_data_into_tab(df, file_path)
Once the data is loaded:
- The table view (
X/Y Data) is updated - The main plot is refreshed
- Toolbar actions are enabled
- Fit controls become accessible