commit 73a811ce1d3a6cdb8ca8b0778547751e4d14b2cc Author: Kyattsukuro Date: Sun Feb 15 22:34:45 2026 +0100 init instructions diff --git a/data/ringe.xlsx b/data/ringe.xlsx new file mode 100644 index 0000000..fbcd6b0 Binary files /dev/null and b/data/ringe.xlsx differ diff --git a/data/zählungen.xlsx b/data/zählungen.xlsx new file mode 100644 index 0000000..85e9a44 Binary files /dev/null and b/data/zählungen.xlsx differ diff --git a/instructions/countings_formater.py b/instructions/countings_formater.py new file mode 100644 index 0000000..ce5e8d3 --- /dev/null +++ b/instructions/countings_formater.py @@ -0,0 +1,60 @@ +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" + }, +] \ No newline at end of file diff --git a/instructions/mappings.py b/instructions/mappings.py new file mode 100644 index 0000000..4124da3 --- /dev/null +++ b/instructions/mappings.py @@ -0,0 +1,343 @@ +SPICIES = { + "Bbar": [ + "B.bar.", + "B.bar", + "BBAR", + "bbar", + "Barbastella", + "barbastellus", + "B.b.", + "B.b", + "BB", + "bb", + ], + "Mbra": [ + "M.bra.", + "M.bra", + "MBRA", + "mbra", + "Myotis brandtii", + "M.br.", + "M.br", + "MBR", + "mbr", + ], + "Mmys": [ + "M.myst.", + "M.myst", + "MMYST", + "mmyst", + "Myotis mystacinus", + "M.mys.", + "M.mys", + "MMYS", + "mmys", + ], + "Ppip": [ + "P.pip.", + "P.pip", + "PPIP", + "ppip", + "Pipistrellus pipistrellus", + ], + "Vmur": [ + "V.mur.", + "Vmur", + "VMUR", + "vmur", + "Vespertilio murinus", + "V.m.", + "V.m", + "VM", + "vm", + ], + "Plespec": [ + "Plec. spec.", + "Pl. spec", + "PLEC SPEC", + "plec spec", + "Plecotus", + "Plec. spe.", + "Pl. spe", + "PLEC SPE", + "plec spe", + "Plecotus species", + ], + "Enil": [ + "E.nil.", + "E.nil", + "ENIL", + "enil", + "Eptesicus nilssonii", + "E.n.", + "E.n", + "EN", + "en", + ], + "Mdas": [ + "M.das.", + "M.das", + "MDAS", + "mdas", + "Myotis dasycneme", + ], + "Mnat": [ + "M.nat.", + "M.nat", + "MNAT", + "mnat", + "Myotis nattereri", + "M.n.", + "M.n", + "MN", + "mn", + ], + "Ppyg": [ + "P.pyg.", + "P.pyg", + "PPYG", + "ppyg", + "Pipistrellus pygmaeus", + ], + "Rhip": [ + "R.hip.", + "R.hip", + "RHIP", + "rhip", + "Rhinolophus hipposideros", + "R.h.", + "R.h", + "RH", + "rh", + ], + "Bart": [ + "Bartfledermaus", + "Bartfledermäuse", + "Bart", + "Bart spec", + "Bärte", + "Bartspec", + ], + "Eser": [ + "E.ser.", + "E.ser", + "ESER", + "eser", + "Eptesicus serotinus", + "E.s.", + "E.s", + "ES", + "es", + ], + "Mdau": [ + "M.dau.", + "M.dau", + "MDAU", + "mdau", + "Myotis daubentonii", + ], + "Nlei": [ + "N.lei.", + "N.lei", + "NLEI", + "nlei", + "Nyctalus leisleri", + "N.l.", + "N.l", + "NL", + "nl", + "Nleisl.", + "N.leis", + "NLEISL", + "nleis", + ], + "Pnat": [ + "P.nat.", + "P.nat", + "PNAT", + "pnat", + "Pipistrellus nathusii", + "P.n.", + "P.n", + "PN", + "pn", + ], + "kl. FM": [ + "kleine Fledermaus", + "kl.FM", + ], + "FM": [ + "Fledermaus", + "spec", + ], + "Cluster": [ + "Klasta", + ], + "unbestimmt": [ + "unbekannt", + "unb.", + "Unbestimmt", + ], + "Malc": [ + "M.alc.", + "M.alc", + "MALC", + "malc", + "Myotis alcathoe", + "M.a.", + "M.a", + "MA", + "ma", + ], + "Mema": [ + "M.ema.", + "M.ema", + "MEMA", + "mema", + "Myotis emarginatus", + "M.e.", + "M.e", + "ME", + ], + "Nnoc": [ + "N.noc.", + "N.noc", + "NNOC", + "nnoc", + "Nyctalus noctula", + "N.n.", + "N.n", + "NN", + "nn", + "N.nyt.", + "N.nyt", + "NNYT", + "nnyt", + ], + "Paur": [ + "P.aur.", + "P.aur", + "PAUR", + "paur", + "Plecotus auritus", + ], + "Mspec": [ + "M.spec.", + "M.spec", + "MSPEC", + "mspec", + "Myotis", + "M.spe.", + "M.spe", + "MSPE", + "mspe", + "Myotis species", + "M", + ], + "Mbec": [ + "M.bech.", + "M.bech", + "MBECH", + "mbech", + "Myotis bechsteinii", + "M.bec.", + "M.bec", + "MBEC", + "mbec", + ], + "Mmyo": [ + "M.myo.", + "M.myo", + "MMYO", + "mmyo", + "Myotis Myotis", + "M.m.", + "M.m", + "MM", + "mm", + ], + "Pkuh": [ + "P.kuh.", + "P.kuh", + "PKUH", + "pkuh", + "Pipistrellus kuhlii", + "P.k.", + "P.k", + "PK", + "pk", + ], + "Paus": [ + "P.aus.", + "Paus", + "PAUS", + "paus", + "Plecotus austriacus", + "P.aust.", + "P.aust", + "PAUST", + "paust", + ], + "Pipspec": [ + "Pip.spec.", + "Pip.spec", + "PIPSPEC", + "pipspec", + "Pipistrellus", + "Pip.spe.", + "Pip.spe", + "PIPSPE", + "pipspe", + "Pipistrellus species", + ], +} + +CATCHED_BY = [ + "Nfg", + "WQK", + "Wst", + "KK", + "AFZ", + "Detektor", +] + +AGE = { + "j": [ + "j", + "juv" + ], + "sub": [ + "sub", + "subad", + "sub ad" + "sub adult", + "sub-adult" + ], + "a": [ + "a", + "ad" + ] +} + +REPRODUCTION = { + "p": [ + "plak", + "pl", + "p" + ], + "g": [ + "g" + ], + "z": [ + "lak", + "l", + "z" + ] +} + +def flatten_dict(d): + flat = {} + for key, values in d.items(): + for value in values: + flat[value] = key + return flat diff --git a/instructions/ring_formater.py b/instructions/ring_formater.py new file mode 100644 index 0000000..bde2d55 --- /dev/null +++ b/instructions/ring_formater.py @@ -0,0 +1,83 @@ +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"]: { + "command": { + "name": "REGEX_MOVE_TO_COL", + "with_input_iteration": flatten_dict(REPRODUCTION), # Moves matching group {{% 1 %}} to "to" + "match": r"^(?:[^ ]* +)*({{% 1 %}}),?(?: .*+)*$", + "to": "Reproduktionsstatus" + } + }, + ["Geschlecht"]: { + "command": { + "name": "REGEX_MOVE_TO_COL", + "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 + "command": { + "name": "REGEX_MOVE_TO_COL", + "match": r"^(?:[^ ]* +)*m(a),?(?: .*+)*$", + "to": "Alter" + } + }, + ["Ringnummer"]: { + "command": { + "name": "REGEX_EDIT_COL", + "match": r"^[^a-zA-Z\d]*([a-zA-Z]*)[^a-zA-Z\d]*(\d+)$", + "to": "{{% 1 %}}{{% 2 %}}" + } + }, + ["Art"]: { + "command": { + "name": "FIND_AND_REPLACE", + "map": SPICIES + } + }, + ["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" + } + } +} + + + +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" + } +] \ No newline at end of file