def findIpColumn(row):
    import re
    iterator = 0
    ipv4_address = re.compile('\n                              ^(?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])$\n                              ', re.VERBOSE)
    ipv6_address = re.compile('\n                              ^(?:(?:[0-9A-Fa-f]{1,4}:)\n                              {6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|::\n                              (?:[0-9A-Fa-f]{1,4}:)\n                              {5}(?:[0-9A-Fa-f]{1,4}:\n                              [0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::\n                              (?:[0-9A-Fa-f]{1,4}:)\n                              {4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::\n                              (?:[0-9A-Fa-f]{1,4}:)\n                              {3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::\n                              (?:[0-9A-Fa-f]{1,4}:)\n                              {2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::\n                              [0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:\n                              [0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::\n                              (?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::\n                              [0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:)\n                              {,6}[0-9A-Fa-f]{1,4})?::)$\n                              ', re.VERBOSE)
    for item in row:
        ipv4_check = ipv4_address.match(item)
        ipv6_check = ipv6_address.match(item)
        if (ipv4_check or ipv6_check):
            return iterator
        iterator = (iterator + 1)
    print('Could not find a column containing IP addresses!')
    print('Error in getuniqueip.py, findIpColumn()')
    exit(1)
def findIpColumn(row):
    import re
    iterator = 0
    ipv4_address = re.compile('\n                              ^(?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])$\n                              ', re.VERBOSE)
    ipv6_address = re.compile('\n                              ^(?:(?:[0-9A-Fa-f]{1,4}:)\n                              {6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|::\n                              (?:[0-9A-Fa-f]{1,4}:)\n                              {5}(?:[0-9A-Fa-f]{1,4}:\n                              [0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::\n                              (?:[0-9A-Fa-f]{1,4}:)\n                              {4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::\n                              (?:[0-9A-Fa-f]{1,4}:)\n                              {3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::\n                              (?:[0-9A-Fa-f]{1,4}:)\n                              {2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::\n                              [0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:\n                              [0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::\n                              (?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\n                              (?:(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5])\\.)\n                              {3}(?:[0-9]|[1-9][0-9]|1[0-9]\n                              {2}|2[0-4][0-9]|25[0-5]))|\n                              (?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::\n                              [0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:)\n                              {,6}[0-9A-Fa-f]{1,4})?::)$\n                              ', re.VERBOSE)
    for item in row:
        ipv4_check = ipv4_address.match(item)
        ipv6_check = ipv6_address.match(item)
        if (ipv4_check or ipv6_check):
            return iterator
        iterator = (iterator + 1)
    print('Could not find a column containing IP addresses!')
    print('Error in getuniqueip.py, findIpColumn()')
    exit(1)