"Nick Burgess" wrote
for root, dirs, files in os.walk('./'):
for f in files:
if f.endswith('.txt'):
allfiles.append(os.path.join(root, f))
myFunction( os.path.join(root,f) )
This returns a list of the *.txt files. Of course now I am stuck on
how to appl
forgot to add this at the top,
allfiles = []
On Tue, May 5, 2009 at 6:15 PM, Nick Burgess wrote:
> for root, dirs, files in os.walk('./'):
> for f in files:
> if f.endswith('.txt'):
> allfiles.append(os.path.join(root, f))
>
> This returns a list of the *.txt files. Of cours
for root, dirs, files in os.walk('./'):
for f in files:
if f.endswith('.txt'):
allfiles.append(os.path.join(root, f))
This returns a list of the *.txt files. Of course now I am stuck on
how to apply the delimiter and search function to the items in the
list..? Any clues/ex
Mr. Gauld is referring to!! I searched python.org and alan-g.me.uk.
Does anyone have a link?
I posted a link to the Python howto and my tutorial is at alan-g.me.uk
You will find it on the contents frame under Regular Expressions...
Its in the Advanced Topics section.
--
Alan Gauld
Author of t
Compiling the regular expression works great, I cant find the tutorial
Mr. Gauld is referring to!! I searched python.org and alan-g.me.uk.
Does anyone have a link?
On Mon, May 4, 2009 at 1:46 PM, Martin Walsh wrote:
> Nick Burgess wrote:
>> So far the script works fine, it avoids printing the
Nick Burgess wrote:
> So far the script works fine, it avoids printing the lines i want and
> I can add new domain names as needed. It looks like this:
>
> #!/usr/bin/python
> import re
>
> outFile = open('outFile.dat', 'w')
> log = file("log.dat", 'r').read().split('Source') # Set the line delim
"Nick Burgess" wrote
for line in log:
if not re.search(r'notneeded.com|notneeded1.com',line):
outFile.write(line)
I tried the in method but it missed any other strings I put in, like
the pipe has no effect. More complex strings will likely be needed so
perhaps re might be better..?
So far the script works fine, it avoids printing the lines i want and
I can add new domain names as needed. It looks like this:
#!/usr/bin/python
import re
outFile = open('outFile.dat', 'w')
log = file("log.dat", 'r').read().split('Source') # Set the line delimiter
for line in log:
if not re.
"Alan Gauld" wrote
How do I make this code print lines NOT containing the string 'Domains'?
Don't use regex, use in:
for line in log:
if "Domains" in line:
print line
Should, of course, be
if "Domains" not in line:
print line
Alan G.
_
"Steve Willoughby" wrote
if re.search != (r'Domains:', line):
Because you are assigning a tuple containing a string and a line of text
to a name which is currently bound to a function object (re.search)
Actually, he's COMPARING the two, not assigning. But comparing a
function object and a
Alan Gauld wrote:
>> if re.search != (r'Domains:', line):
>
> Because you are assigning a tuple containing a string and a line of text
> to a name which is currently bound to a function object (re.search)
Actually, he's COMPARING the two, not assigning. But comparing a
function object and a tupl
"Nick Burgess" wrote
How do I make this code print lines NOT containing the string 'Domains'?
Don't use regex, use in:
for line in log:
if "Domains" in line:
print line
This does not work...
if re.search != (r'Domains:', line):
Because you are assigning a tuple containing
Nick Burgess wrote:
> How do I make this code print lines NOT containing the string 'Domains'?
>
>
> import re
> for line in log:
> if re.search (r'Domains:', line):
> print line
>
>
> This does not work...
>
> if re.search != (r'Domains:', line):
re.search (r'Domains:', line)
is
How do I make this code print lines NOT containing the string 'Domains'?
import re
for line in log:
if re.search (r'Domains:', line):
print line
This does not work...
if re.search != (r'Domains:', line):
___
Tutor maillist - Tutor@pytho
14 matches
Mail list logo