praneethng praneethng - 1 year ago 98
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

Answer Source

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)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download