physics_workload.app.management.load_utils¶
Utility functions for loading CSV and XLSX files.
Attributes¶
Functions¶
|
Takes a path and makes sure it's a CSV file. |
|
Takes a path and makes sure it's a CSV file. |
|
Strips whitespace from all the text columns of a dataframe. |
|
Converts a set of columns from floats/text/whatever into ints, |
|
Converts a set of columns from percentages (expressed as text or equations) into floats. |
|
Loads the Units and their task rows from the Load Master tab of the spreadsheet |
|
Loads non-units tasks from the Load Master tab of the spreadsheet |
|
Loads the "Staff Tasks" sheet of the Excel file. |
|
Loads the "Staff Contracts" sheet of the Excel file. |
Module Contents¶
- physics_workload.app.management.load_utils.logger: logging.Logger¶
- physics_workload.app.management.load_utils.UNIT_PREFIXES: set[str]¶
- physics_workload.app.management.load_utils.ADMIN_PREFIXES: set[str]¶
- physics_workload.app.management.load_utils.SPECIAL_CODES: set[str]¶
- physics_workload.app.management.load_utils.TITLE_UNIT_LEAD: str = 'Unit Lead'¶
- physics_workload.app.management.load_utils.TITLE_UNIT_DEPUTY: str = 'Deputy Lead'¶
- physics_workload.app.management.load_utils.TITLE_PROJECT_MARKING: str = 'Project Marking'¶
- physics_workload.app.management.load_utils.TITLE_DISSERTATION: str = 'Dissertation Marking'¶
- physics_workload.app.management.load_utils.UNIT_TUITION: str = 'TUTOR'¶
- physics_workload.app.management.load_utils.csv_file_only(param: str) pathlib.Path[source]¶
Takes a path and makes sure it’s a CSV file.
- Parameters:
param – The string input parameter.
- Raises:
ArgumentTypeError – If it’s not a CSV file.
- Returns:
That string as a file path.
- physics_workload.app.management.load_utils.xlsx_file_only(param: str) pathlib.Path[source]¶
Takes a path and makes sure it’s a CSV file.
- Parameters:
param – The string input parameter.
- Raises:
ArgumentTypeError – If it’s not a CSV file.
- Returns:
That string as a file path.
- physics_workload.app.management.load_utils.strip_dataframe_whitespace(dataframe: pandas.DataFrame)[source]¶
Strips whitespace from all the text columns of a dataframe.
- Parameters:
dataframe – The dataframe to strip.
- Returns:
None, this is done in-place.
- physics_workload.app.management.load_utils.convert_columns_to_ints(dataframe: pandas.DataFrame, columns: list[str])[source]¶
Converts a set of columns from floats/text/whatever into ints, and replaces any problems with 0.
- Parameters:
dataframe – The dataframe to convert.
columns – The list of columns to work over.
- Returns:
None, this is done in-place.
- physics_workload.app.management.load_utils.convert_percentage_columns_to_floats(dataframe: pandas.DataFrame, columns: list[str])[source]¶
Converts a set of columns from percentages (expressed as text or equations) into floats.
- Parameters:
dataframe – The dataframe to convert.
columns – The list of columns to work over.
- Returns:
None, this is done in-place.
- physics_workload.app.management.load_utils.load_units_from_load_master_excel(path: pathlib.Path) pandas.DataFrame[source]¶
Loads the Units and their task rows from the Load Master tab of the spreadsheet
DF keys are approached from the perspective of a Unit model.
- Parameters:
path – The Excel spreadsheet to read.
- Returns:
The data.
- physics_workload.app.management.load_utils.load_nonunit_tasks_from_excel(path: pathlib.Path) pandas.DataFrame[source]¶
Loads non-units tasks from the Load Master tab of the spreadsheet
DF keys are approached from the perspective of a Unit model.
- Parameters:
path – The Excel spreadsheet to read.
- Returns:
The data.
- physics_workload.app.management.load_utils.load_staff_tasks_from_excel(path: pathlib.Path) pandas.DataFrame[source]¶
Loads the “Staff Tasks” sheet of the Excel file.
This has lines for each task, plus a final line for each staff member saying “Total”.
- Parameters:
path – The Excel spreadsheet to read.
- Returns:
A dataframe that represents the “Staff tasks” sheet.
- physics_workload.app.management.load_utils.load_staff_contracts_from_excel(path: pathlib.Path) pandas.DataFrame[source]¶
Loads the “Staff Contracts” sheet of the Excel file.
Some of the columns have trailing whitespace in the names (???).
- Parameters:
path – The Excel spreadsheet to read.
- Returns:
A dataframe that represents the “Staff Contract Detail” sheet.