Re: search speed

2009-02-01 Thread Aaron Watters
On Jan 30, 3:49 am, "Diez B. Roggisch" wrote: > alex23 gave you a set of tools that you can use for full-text-search. > However, that's not necessarily the best thing to do if things have a > record-like structure. In Nucular (and others I think) you can do searches for terms anywhere (full text)

Re: search speed

2009-01-31 Thread Tim Rowe
2009/1/30 Scott David Daniels : > Be careful with your assertion that a regex is faster, it is certainly > not always true. I was careful *not* to assert that a regex would be faster, merely that it was *likely* to be in this case. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-

Re: glob.fnmatch (was "search speed")

2009-01-31 Thread rdmurray
Quoth Tim Chase : > rdmur...@bitdance.com wrote: > > What you want is: > > > > from fnmatch import fnmatch > > Oh, that's head-smackingly obvious now...thanks! > > My thought process usually goes something like > > """ > I want to do some file-name globbing > > there's a glob module that l

Re: glob.fnmatch (was "search speed")

2009-01-31 Thread Tim Chase
rdmur...@bitdance.com wrote: Quoth Tim Chase : PS: as an aside, how do I import just the fnmatch function? I tried both of the following and neither worked: from glob.fnmatch import fnmatch from glob import fnmatch.fnmatch I finally resorted to the contortion coded below in favor of

Re: search speed

2009-01-31 Thread anders
Tanks everyone that spent time helping my, the help was great. Best regards Anders -- http://mail.python.org/mailman/listinfo/python-list

Re: search speed

2009-01-30 Thread rdmurray
Quoth Tim Chase : > PS: as an aside, how do I import just the fnmatch function? I > tried both of the following and neither worked: > >from glob.fnmatch import fnmatch >from glob import fnmatch.fnmatch > > I finally resorted to the contortion coded below in favor of >import glob >

Re: search speed

2009-01-30 Thread Tim Chase
I have written a Python program that serach for specifik customer in files (around 1000 files) the trigger is LF01 + CUSTOMERNO While most of the solutions folks have offered involve scanning all the files each time you search, if the content of those files doesn't change much, you can build a

Re: search speed

2009-01-30 Thread Jervis Whitley
> > > Today this works fine, it saves me a lot of manuall work, but a seach > takes around 5 min, > so my questin is is there another way of search in a file > (Today i step line for line and check) > If the files you are searching are located at some other location on a network, you may find that

Re: search speed

2009-01-30 Thread Stefan Behnel
Diez B. Roggisch wrote: > that's not necessarily the best thing to do if things have a > record-like structure. The canonical answer to this is then to use a > database to hold the data, instead of flat files. So if you have any > chance to do that, you should try & stuff things in there. It's wor

Re: search speed

2009-01-30 Thread Stefan Behnel
D'Arcy J.M. Cain wrote: > On Fri, 30 Jan 2009 15:46:33 +0200 > Justin Wyer wrote: >> $ find -name "*" -exec grep -nH "LF01" {} \; >> | cut -d ":" -f 1 | sort | uniq > > I know this isn't a Unix group but please allow me to suggest instead; > > $ grep -lR LF01 That's a very good advice. I ha

Re: search speed

2009-01-30 Thread John Machin
D'Arcy J.M. Cain druid.net> writes: > > On Fri, 30 Jan 2009 15:46:33 +0200 > Justin Wyer gmail.com> wrote: > > $ find -name "*" -exec grep -nH "LF01" {} \; > > | cut -d ":" -f 1 | sort | uniq > > I know this isn't a Unix group but please allow me to suggest instead; > > $ grep -lR LF01

Re: search speed

2009-01-30 Thread Scott David Daniels
Tim Rowe wrote: But even without going to a full database solution it might be possible to make use of the flat file structure. For example, does the "LF01" have to appear at a specific position in the input line? If so, there's no need to search for it in the complete line. *If* there is an

Re: search speed

2009-01-30 Thread Tim Rowe
2009/1/30 Diez B. Roggisch : > No. Because nobody can automagically infer whatever structure your files > have. Just so. But even without going to a full database solution it might be possible to make use of the flat file structure. For example, does the "LF01" have to appear at a specific positi

Re: search speed

2009-01-30 Thread D'Arcy J.M. Cain
On Fri, 30 Jan 2009 15:46:33 +0200 Justin Wyer wrote: > $ find -name "*" -exec grep -nH "LF01" {} \; > | cut -d ":" -f 1 | sort | uniq I know this isn't a Unix group but please allow me to suggest instead; $ grep -lR LF01 -- D'Arcy J.M. Cain | Democracy is three wolves http://www

Re: search speed

2009-01-30 Thread Justin Wyer
On Fri, Jan 30, 2009 at 1:51 AM, anders wrote: > Hi! > I have written a Python program that serach for specifik customer in > files (around 1000 files) > the trigger is LF01 + CUSTOMERNO > > So a read all fils with dirchached > > Then a loop thru all files each files is read with readLines() and

search speed

2009-01-30 Thread anders
Hi! I have written a Python program that serach for specifik customer in files (around 1000 files) the trigger is LF01 + CUSTOMERNO So a read all fils with dirchached Then a loop thru all files each files is read with readLines() and after that scaned Today this works fine, it saves me a lot of

Re: search speed

2009-01-30 Thread Diez B. Roggisch
anders schrieb: Hi! I have written a Python program that serach for specifik customer in files (around 1000 files) the trigger is LF01 + CUSTOMERNO So a read all fils with dirchached Then a loop thru all files each files is read with readLines() and after that scaned Today this works fine, it

Re: search speed

2009-01-29 Thread alex23
On Jan 30, 2:56 pm, r wrote: > On Jan 29, 5:51 pm, anders wrote: > > > if file.findInFile("LF01"): > > Is there any library like this ?? > > Best Regards > > Anders > > Yea, it's called a for loop! > > for line in file: >     if "string" in line: >         do_this() Which is what the OP is alrea

Re: search speed

2009-01-29 Thread r
On Jan 29, 5:51 pm, anders wrote: > if file.findInFile("LF01"): > Is there any library like this ?? > Best Regards > Anders Yea, it's called a for loop! for line in file: if "string" in line: do_this() -- http://mail.python.org/mailman/listinfo/python-list