[Python] QGIS Special Character Name Comparison Gives Partial results

Discussão em 'Python' iniciado por Stack, Abril 16, 2025.

  1. Stack

    Stack Membro Participativo

    I've been trying to come up with a solution in my company to take a name column from layer A to compare and spit out the matching names that are in layer B.

    I found some solution but for some reason, it's spitting out only the partial results. When I go back to make sure if it captured all, it missed something. I tried my best to find a reason, and what it came down to was it has to do with askii code in the background. So I found some code to enhance my current one, but it's still the same and I don't know how to go about it anymore. I'm comparing Romanian characters just fyi.

    And here's the code.

    Function Editor

    from qgis.utils import iface
    import unicodedata
    import re

    @qgsfunction(args='auto', group='Custom')
    def normalize_name(name, feature, parent):
    if name is None:
    return ''

    name = name.strip().lower()
    name = re.sub(r'\u200b|\ufeff|\xa0', '', name)
    name = unicodedata.normalize('NFC', name)
    return name


    Expression

    array_contains(
    aggregate(
    layer:='RomaniaInspireData',
    aggregate:='array_agg',
    expression:= normalize_name("name")
    ),
    normalize_name("FULL_NAME")
    )


    Any help would be appreciated. Thank you!

    Continue reading...

Compartilhe esta Página