How to remove empty lines with re?
Bror Johansson
bror.johansson at saabtech.se
Fri Oct 10 10:01:19 EDT 2003
More information about the Python-list mailing list
Fri Oct 10 10:01:19 EDT 2003
- Previous message (by thread): How to remove empty lines with re?
- Next message (by thread): How to remove empty lines with re?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"ted" <tedNOSPAM94107 at yahoo.com> wrote in message news:vocoudjtp6vv25 at corp.supernews.com... > I'm having trouble using the re module to remove empty lines in a file. > > Here's what I thought would work, but it doesn't: > > import re > f = open("old_site/index.html") > for line in f: > line = re.sub(r'^\s+$|\n', '', line) > print line > nonempty = [x for x in f if not x.strip()] /BJ
- Previous message (by thread): How to remove empty lines with re?
- Next message (by thread): How to remove empty lines with re?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list