How to get IP addresses from ip2location database?

271 views Asked by At

I have downloaded IP2Proxy™ LITE database in csv format, below is the data in it

enter image description here

could anybody please help me how to read the ip addresses using python or powershell as it seems in plain number. Also please explain what does 1st to column represents.

1

There are 1 answers

3
SIGHUP On BEST ANSWER

Here's how you can convert those values into a string representation of an IPv4 address:

def convert(ip):
        def _genip(n):
            for shift in range(24, -8, -8):
                yield f'{(n >> shift) & 0xff:03d}'
        return '.'.join(list(_genip(int(ip))))
print(convert('34676992'))

Output:

002.017.033.000