def METHOD_NAME(row, subdivs):
    # Skip if no LOCODE
    if row["LOCODE"] == "":
        return
    actor_id = f'{row["ISO 3166-1"].strip()} {row["LOCODE"].strip()}'
    # Test for function = road station; not perfect but...
    # Test if name is air, rail, or ferry port with regular expression
    regex = (
        '^Port\sof'
        '|\sPort$'
        '|\sPt\s?/'
        '|Pt\.'
        '|\sPort\s?/'
        '|\sApt\s?/'
        '|\sApt$'
        '|\sRailway\sStation.*'
        '|\sFerryport'
        '|Ferry\sPort'
        '|\sTerminal'
        '|.+Airport'
    )
    if re.search(regex, row["Name"]) or row["ISO 3166-1"].strip() == "XZ":
        # We want to delete bad existing rows
        write_output_row("Actor.delete", ["actor_id"], {
            "actor_id": actor_id
        })
        write_output_row("ActorName.delete", ["actor_id"], {
            "actor_id": actor_id
        })
        write_output_row("ActorIdentifier.delete", ["actor_id"], {
            "actor_id": actor_id
        })
        write_output_row("Territory.delete", ["actor_id"], {
            "actor_id": actor_id
        })
    else:
        if row["SubDiv"] == "":
            parent_id = row["ISO 3166-1"].strip()
        else:
            subdiv_id = f'{row["ISO 3166-1"].strip()}-{row["SubDiv"].strip()}'
            if subdiv_id in subdivs:
                parent_id = subdiv_id
            else:
                parent_id = row["ISO 3166-1"].strip()
        write_output_row("Actor", ACTOR_COLUMNS, {
            "actor_id": actor_id,
            "type": "city",
            "name": row["Name"],
            "is_part_of": parent_id,
            "datasource_id": DATASOURCE["datasource_id"]
        })
        write_output_row("ActorName", ACTOR_NAME_COLUMNS, {
            "actor_id": actor_id,
            "name": row["Name"],
            "language": "und",
            "preferred": 0,
            "datasource_id": DATASOURCE["datasource_id"]
        })
        write_output_row("ActorIdentifier", ACTOR_IDENTIFIER_COLUMNS, {
            "actor_id": actor_id,
            "identifier": actor_id,
            "namespace": "UNLOCODE",
            "datasource_id": DATASOURCE["datasource_id"]
        })
        if (row["NameWoDiacritics"] != row["Name"]):
            write_output_row("ActorName", ACTOR_NAME_COLUMNS, {
                "actor_id": actor_id,
                "name": row["NameWoDiacritics"],
                "language": "und",
                "preferred": 0,
                "datasource_id": DATASOURCE["datasource_id"]
            })
        if row["Coordinates"] != "":
            (lat, lng) = coordinates_to_decimal(row["Coordinates"])
            write_output_row("Territory", TERRITORY_COLUMNS, {
                "actor_id": actor_id,
                "lat": lat,
                "lng": lng,
                "datasource_id": DATASOURCE["datasource_id"]
            })