All pastes #216483 Raw Edit

Unnamed

public text v1 · immutable
#216483 ·published 2006-10-23 03:58 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)
    for i in xrange(daysBack):
        daystr = str(day)
        day -= day_delta
        for line in dataLines:
            if daystr in line:
                yield line
                dataLines.remove(line)

dataLines = list(lastSevenDays(dataLines, 7))