If x is between y and z, print, no output with python csv
Question: I'm trying to get the first row of a csv to print when the condition is
between the second and third row.

Here is my current code:

    
    
    from libnmap.parser import NmapParser
    import csv
    from netaddr import *
    
    
    ip = raw_input("Enter an IP: ")
    addr = (int(IPAddress(ip)))
    
    with open('DHCPranges.csv', 'rb') as csvfile:
        reader = csv.DictReader(csvfile, delimiter=',')
        for row in reader:  
            if addr >= (int(IPAddress(row['start_address*'])) and addr <= (int(IPAddress(row['end_address*'])))):
                print (row['Network'])
    

When I input the IP, I don't get a print out. I have verified that the addr
variable is working properly, so the if statement must be wrong somehow.

The csv is created like so, with commas:

    
    
    Network,start_address*,end_address*
    Matt's network,10.0.0.1,10.0.1.100
    Chris's network,10.0.1.102,10.0.2.100
    


Answer: You specify delimiter=',' but there are not comma delimeters in your file.
What is the actual delimiter? Tab? More than one space in the same place?

Try printing row.keys() in the loop, before the for line. If the csv example
is correct, it will give a single string.

