60 lines
1.3 KiB
Python
60 lines
1.3 KiB
Python
from mappings import *
|
|
|
|
EXPECTED_INPUT_TABLE_SCHEMA = [
|
|
"Anzahl",
|
|
"Art",
|
|
"Geschlecht",
|
|
"Datum",
|
|
"Ort",
|
|
"Davon m",
|
|
"Davon w",
|
|
"Fangart",
|
|
"Bemerkung"
|
|
]
|
|
|
|
EXPECTED_OUTPUT_TABLE_SCHEMA = EXPECTED_INPUT_TABLE_SCHEMA.remove("Geschlecht")
|
|
|
|
COL_INSTRUCTIONS = {
|
|
["Fangart"]: {
|
|
"command": {
|
|
"name": "FIND_AND_REPLACE",
|
|
"map": CATCHED_BY
|
|
}
|
|
},
|
|
["Ort"]: {
|
|
"command": {
|
|
"name": "REGEX_MOVE_TO_COL",
|
|
"with_input_iteration": flatten_dict(CATCHED_BY), # Moves matching group {{% 1 %}} to "to"
|
|
"match": r"^(?:[^ ]* +)*({{% 1 %}}),?(?: .*+)*$",
|
|
"to": "Fangart"
|
|
}
|
|
},
|
|
["Fangart"]: {
|
|
"command": {
|
|
"name": "REGEX_EDIT_COL",
|
|
"match": r"^ *$",
|
|
"to": "1"
|
|
}
|
|
},
|
|
}
|
|
|
|
ROW_INSTRUCTION = [
|
|
{
|
|
"command": "CONDITIONAL_COPY",
|
|
"when_regex": {
|
|
"Geschlecht": r"^(?:[^ ]* +)*(m),?(?: .*+)*$",
|
|
"Anzahl": r"/d"
|
|
},
|
|
"source": "Anzahl",
|
|
"target": "Davon m"
|
|
},
|
|
{
|
|
"command": "CONDITIONAL_COPY",
|
|
"when_regex": {
|
|
"Geschlecht": r"^(?:[^ ]* +)*(w),?(?: .*+)*$",
|
|
"Anzahl": r"/d"
|
|
},
|
|
"source": "Anzahl",
|
|
"target": "Davon w"
|
|
},
|
|
] |