62 lines
1.4 KiB
Python
62 lines
1.4 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)
|
|
EXPECTED_OUTPUT_TABLE_SCHEMA.remove("Geschlecht")
|
|
|
|
COL_INSTRUCTIONS = {
|
|
("Art",): {
|
|
"command": "FIND_AND_REPLACE",
|
|
"reqire_full_match": True,
|
|
"map": SPICIES
|
|
},
|
|
("Ort",): {
|
|
"command": "REGEX_MOVE_TO_COL",
|
|
"with_input_iteration": CATCHED_BY, # Moves matching group {{% 0 %}} to "to"
|
|
"match": r"^(?:[^ ]* +)*({{% 0 %}}),?(?: .*+)*$",
|
|
"to": "Fangart"
|
|
},
|
|
("Anzahl",): {
|
|
"command": "REGEX_EDIT_COL",
|
|
"match": r"^ *$",
|
|
"replace_with": "1"
|
|
},
|
|
("Anzahl",): {
|
|
"command": "REGEX_GROUP_VALUEBASED_CHOOS",
|
|
"match": r"^ *([0-9]+) *oder *([0-9]+) *$",
|
|
"highest": True
|
|
},
|
|
}
|
|
|
|
ROW_INSTRUCTION = [
|
|
{
|
|
"command": "CONDITIONAL_COPY",
|
|
"when_regex": {
|
|
"Geschlecht": r"^(?:[^ ]* +)*(m),?(?: .*+)*$",
|
|
"Anzahl": r"([0-9]+)"
|
|
},
|
|
"source": "Anzahl",
|
|
"target": "Davon m"
|
|
},
|
|
{
|
|
"command": "CONDITIONAL_COPY",
|
|
"when_regex": {
|
|
"Geschlecht": r"^(?:[^ ]* +)*(w),?(?: .*+)*$",
|
|
"Anzahl": r"([0-9]+)"
|
|
},
|
|
"source": "Anzahl",
|
|
"target": "Davon w"
|
|
},
|
|
] |