def getTimerange(filename, unique_ip_address):
    "Naive method to determine the time range during which an IP\n    address appears in a logfile.\n\n    This is sort of hacky. I'm using timestring to process fairly arbitrary\n    text input strings for dates from logs, converting those into POSIX\n    dates and times, and then comparing that to a simple integer stored\n    in the object to establish our range.\n\n    Parameters:\n        filename: The logfile we are examining in this job.\n        unique_ip_address: A list of IpAddress() objects.\n\n    Returns:\n        unique_ip_address: A list of unique IPAddress()\n            objects with dates included.\n    "
    import csv
    import dateparser
    print('Determining date/time ranges for each unique IP...')
    file = open(filename, 'r', encoding='utf-8')
    logfile_reader = csv.reader(file)
    next(logfile_reader)
    row = next(logfile_reader)
    ip_column = findIpColumn(row)
    time_column = findTimeColumn(row)
    file.seek(0)
    next(logfile_reader)
    for ip in unique_ip_address:
        file.seek(0)
        for entry in logfile_reader:
            if (ip.ip == entry[ip_column]):
                entry_time = dateparser.parse(entry[time_column], settings={'TIMEZONE': 'UTC', 'RETURN_AS_TIMEZONE_AWARE': True}).timestamp()
                if (ip.startTime > entry_time):
                    ip.startTime = entry_time
                if (ip.endTime < entry_time):
                    ip.endTime = entry_time
    return unique_ip_address
Naive method to determine the time range during which an IP
address appears in a logfile.

This is sort of hacky. I'm using timestring to process fairly arbitrary
text input strings for dates from logs, converting those into POSIX
dates and times, and then comparing that to a simple integer stored
in the object to establish our range.

Parameters:
    filename: The logfile we are examining in this job.
    unique_ip_address: A list of IpAddress() objects.

Returns:
    unique_ip_address: A list of unique IPAddress()
        objects with dates included.
def getTimerange(filename, unique_ip_address):
    "Naive method to determine the time range during which an IP\n    address appears in a logfile.\n\n    This is sort of hacky. I'm using timestring to process fairly arbitrary\n    text input strings for dates from logs, converting those into POSIX\n    dates and times, and then comparing that to a simple integer stored\n    in the object to establish our range.\n\n    Parameters:\n        filename: The logfile we are examining in this job.\n        unique_ip_address: A list of IpAddress() objects.\n\n    Returns:\n        unique_ip_address: A list of unique IPAddress()\n            objects with dates included.\n    "
    import csv
    import dateparser
    print('Determining date/time ranges for each unique IP...')
    file = open(filename, 'r', encoding='utf-8')
    logfile_reader = csv.reader(file)
    next(logfile_reader)
    row = next(logfile_reader)
    ip_column = findIpColumn(row)
    time_column = findTimeColumn(row)
    file.seek(0)
    next(logfile_reader)
    for ip in unique_ip_address:
        file.seek(0)
        for entry in logfile_reader:
            if (ip.ip == entry[ip_column]):
                entry_time = dateparser.parse(entry[time_column], settings={'TIMEZONE': 'UTC', 'RETURN_AS_TIMEZONE_AWARE': True}).timestamp()
                if (ip.startTime > entry_time):
                    ip.startTime = entry_time
                if (ip.endTime < entry_time):
                    ip.endTime = entry_time
    return unique_ip_address