Re: [Tutor] searching for an ip and subnets in a dir of csv's

2009-07-29 Thread Nick Burgess
join(row) On Wed, Jul 29, 2009 at 8:13 AM, Wayne wrote: > On Tue, Jul 28, 2009 at 9:36 PM, Nick Burgess > wrote: >> >> Good evening List, >> >> I am trying to have this script search for an IP or nearest subnet >> match in a dir of csv's. It works

[Tutor] searching for an ip and subnets in a dir of csv's

2009-07-28 Thread Nick Burgess
Good evening List, I am trying to have this script search for an IP or nearest subnet match in a dir of csv's. It works with an absolute match, It will be receiving a whole IP address, so if there is no absolute match no data is returned, however if it is listed somewhere in a subnet I want to kn

Re: [Tutor] converting xls to csv

2009-06-06 Thread Nick Burgess
Thanks everyone, the following code works great. It returns the name of the file and the row that matched the reqex. Is it posible to take the regex compile from user input? To make it take an argument, like > csvSearch.py 10.192.55 af = re.compile(sys.argv[1]) pattern = re.compile(af)

Re: [Tutor] converting xls to csv

2009-06-06 Thread Nick Burgess
or cell in row: if pattern.search(cell): print ', '.join(row) XLS.xls.org1.csv XLS.xls.org2.csv XLS.xls.org3.csv On Sat, Jun 6, 2009 at 3:33 PM, Emile van Sebille wrote: > On 6/6/2009 12:19 PM Nick Burgess said... >> >> Thank you. The data is

Re: [Tutor] converting xls to csv

2009-06-06 Thread Nick Burgess
TypeError: coercing to Unicode: need string or buffer, list found On Sun, May 31, 2009 at 12:45 PM, Richard Lovely wrote: > 2009/5/31 Nick Burgess : >> Got it. >> >> the row is not a string or buffer but the cell is.. >> >> for row in spamReader: >>    for ce

Re: [Tutor] converting xls to csv

2009-05-31 Thread Nick Burgess
Got it. the row is not a string or buffer but the cell is.. for row in spamReader: for cell in row: if pattern.search(cell): print ', '.join(row) On Sun, May 31, 2009 at 5:09 AM, Nick Burgess wrote: > Thank you for your response and my apologies for t

Re: [Tutor] converting xls to csv

2009-05-31 Thread Nick Burgess
9 it returns all of the rows, so I now its reading OK.. Thanks for your time, -nick On Sun, May 31, 2009 at 3:57 AM, Alan Gauld wrote: > > "Nick Burgess" wrote >> >> I am trying to make this code work.  I don't have any experience with >> defining things

[Tutor] converting xls to csv

2009-05-30 Thread Nick Burgess
Hi list, I am trying to make this code work. I don't have any experience with defining things and this is my second program. The error returmed is "SyntaxError: invalid syntax" code: #!/usr/bin/python import cvs def convertXLS2CSV(aFile): '''converts a MS Excel file to csv w/ the same n

Re: [Tutor] returning the entire line when regex matches

2009-05-05 Thread Nick Burgess
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

Re: [Tutor] returning the entire line when regex matches

2009-05-05 Thread Nick Burgess
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

Re: [Tutor] returning the entire line when regex matches

2009-05-04 Thread Nick Burgess
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 pri

Re: [Tutor] returning the entire line when regex matches

2009-05-04 Thread Nick Burgess
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.

[Tutor] returning the entire line when regex matches

2009-05-03 Thread Nick Burgess
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