praneethng praneethng - 7 months ago 54
Python Question

python script to key in the date range from a file and redirect the output

content was not related to the words keyed in


Indentation is wrong so your loop does nothing useful. Only last line is processed in the end (s is the match for the last line):

fix: indent properly from 2nd line:

for line in t:
    s = p.match(line)
    if s:
        sdate_str ="date")
        # sort the dates to get only ones between range
        sdate = datetime.datetime.strptime(sdate_str, "%Y%m%d")
        if sdate >= lbound_date and sdate <= rbound_date:

(sorry for such a trivial answer)