from mappings import * EXPECTED_INPUT_TABLE_SCHEMA = [ "Ringnummer", "Art", "Geschlecht" "Alter", "Reproduktionsstatus", "Unterarmlänge", "Gewicht", "Datum", "Ort", "Fangart", "Uhrzeit", "Proben", "Wiederfunde", "Bemerkung" ] EXPECTED_OUTPUT_TABLE_SCHEMA = EXPECTED_INPUT_TABLE_SCHEMA COL_INSTRUCTIONS = { ["Geschlecht"]: { "name": "REGEX_MOVE_TO_COL", "command": { "with_input_iteration": flatten_dict(REPRODUCTION), # Moves matching group {{% 1 %}} to "to" "match": r"^(?:[^ ]* +)*({{% 1 %}}),?(?: .*+)*$", "to": "Reproduktionsstatus" } }, ["Geschlecht"]: { "name": "REGEX_MOVE_TO_COL", "command": { "with_input_iteration": flatten_dict(AGE), # Moves matching group {{% 1 %}} to "to" "match": r"^(?:[^ ]* +)*({{% 1 %}}),?(?: .*+)*$", "to": "Alter" } }, ["Geschlecht"]: { # Special case ma -> Geschlecht a | Alter a "name": "REGEX_MOVE_TO_COL", "command": { "match": r"^(?:[^ ]* +)*m(a),?(?: .*+)*$", "to": "Alter" } }, ["Ringnummer"]: { "name": "REGEX_EDIT_COL", "command": { "match": r"^[^a-zA-Z\d]*([a-zA-Z]*)[^a-zA-Z\d]*(\d+)$", "to": "{{% 1 %}}{{% 2 %}}" } }, ["Art"]: { "name": "FIND_AND_REPLACE", "command": { "map": SPICIES } }, ["Ort"]: { "name": "REGEX_MOVE_TO_COL", "command": { "with_input_iteration": flatten_dict(CATCHED_BY), # Moves matching group {{% 1 %}} to "to" "match": r"^(?:[^ ]* +)*({{% 1 %}}),?(?: .*+)*$", "to": "Fangart" } } } ROW_INSTRUCTIONS = [ { "command": "ROW_COLOR_TO_BOOL", # Match when found as text color in any col of the row "color": ["#ff0000", "#0000ff"], "approximate": True, "column": "Wiederfunde", "value": "TRUE" }, { "command": "ROW_COPY_REMAINING" } ]