---------------------------- On Sun, Nov 9, 2014 10:51 PM CET Syed Khalid wrote:
>Albert, > >Thanks a million for script, > >It worked fine after I closed the bracket. > > >import glob, codecs, re, os > >regex = re.compile(r"Age: |Sex: |House No: ") # etc etc > >for txt in glob.glob("D:/Python/source/*.txt"): > with codecs.open(txt, encoding="utf-8") as f: > oldlines = f.readlines() > for i, line in enumerate(oldlines): > if "Elector's Name:" in line: > break > newlines = [regex.sub(", line).strip().replace("-", "_") for line in >oldlines[i:]] You're welcome newlines = [regex.sub("", line).strip().replace("-", "_") for line in oldlines[i:] if line.strip()] -- https://mail.python.org/mailman/listinfo/python-list