geonature.core.imports.checks.dataframe.utils#
Functions#
|
Decorator for check functions. |
|
For rows which trigger old_code error on all old_columns, these errors are replaced |
|
Reports an error found in the dataframe, updates the validity column and insert |
Module Contents#
- geonature.core.imports.checks.dataframe.utils.dataframe_check(check_function)[source]#
Decorator for check functions. Check functions must yield errors, and return updated_cols (or None if no column have been modified).
- geonature.core.imports.checks.dataframe.utils.error_replace(old_code, old_columns, new_code, new_column=None)[source]#
For rows which trigger old_code error on all old_columns, these errors are replaced by new_code error on new_column. Usage example:
@dataframe_check @error_replace(ImportCodeError.MISSING_VALUE, {« WKT », »latitude », »longitude »}, ImportCodeError.NO_GEOM, « Champs géométriques ») def check_required_values:
…
=> MISSING_VALUE on WKT, latitude and longitude are replaced by NO-GEOM on « Champs géométrique »
If new_code is None, error is deleted
- geonature.core.imports.checks.dataframe.utils.report_error(imprt, entity, df, error)[source]#
Reports an error found in the dataframe, updates the validity column and insert the error in the t_user_errors table.
Parameters#
- imprtImport
The import entity.
- entityEntity
The entity to check.
- dfpandas.DataFrame
The dataframe containing the data.
- errordict
The error to report. It should have the following keys: - invalid_rows : DataFrame
The rows with errors.
- error_codestr
The name of the error code.
- columnstr
The column with errors.
- commentstr, optional
A comment to add to the error.
Returns#
- set
set containing the name of the entity validity column.
Raises#
- Exception
If the error code is not found.