fledermaus/instructions/countings_formater.py
2026-03-13 16:47:31 +01:00

55 lines
1.2 KiB
Python

from .mappings import *
from copy import deepcopy
EXPECTED_INPUT_TABLE_SCHEMA = [
"Anzahl",
"Art",
"Geschlecht",
"Datum",
"Ort",
"Davon m",
"Davon w",
"Fangart",
"Bemerkung"
]
EXPECTED_OUTPUT_TABLE_SCHEMA = deepcopy(EXPECTED_INPUT_TABLE_SCHEMA).remove("Geschlecht")
COL_INSTRUCTIONS = {
("Art",): {
"command": "FIND_AND_REPLACE",
"map": SPICIES
},
("Ort",): {
"command": "REGEX_MOVE_TO_COL",
"with_input_iteration": CATCHED_BY, # Moves matching group {{% 1 %}} to "to"
"match": r"^(?:[^ ]* +)*({{% 1 %}}),?(?: .*+)*$",
"to": "Fangart"
},
("Fangart",): {
"command": "REGEX_EDIT_COL",
"match": r"^ *$",
"replace_with": "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"
},
]