All pastes #216474 Raw Edit

Mine

public text v1 · immutable
#216474 ·published 2006-10-23 03:50 UTC
rendered paste body

import datetime

def lastSevenDays(dataLines, daysBack):
    """Filter records fewer than daysBack days old."""
    day = datetime.date.today()
    day_delta = timedelta(days=1)
    daystrings = []
    for i in range(daysBack):
        daystrings.append(str(day))
        day -= day_delta

    for line in dataLines:
        for string in daystrings:
            if string in line:
                yield line

dataLines = list(lastSevenDays(dataLines, 7))