<br><br><div class="gmail_quote">On Fri, Jan 30, 2009 at 1:51 AM, anders <span dir="ltr"><<a href="mailto:anders.u.persson@gmail.com">anders.u.persson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi!<br>
I have written a Python program that serach for specifik customer in<br>
files (around 1000 files)<br>
the trigger is LF01 + CUSTOMERNO<br>
<br>
So a read all fils with dirchached<br>
<br>
Then a loop thru all files each files is read with readLines() and<br>
after that scaned<br>
<br>
Today this works fine, it saves me a lot of manuall work, but a seach<br>
takes around 5 min,<br>
so my questin is is there another way of search in a file<br>
(Today i step line for line and check)</blockquote><div><br>Do you require this information in a python application, seems like you did this manually before?<br><br>If not then python is the wrong tool for this job, you can simply use this command on a unix-like environment (install cygwin, if you are on windows)<br>
<br>$ find <path_to_dirs_containing_files> -name "*" -exec grep -nH "LF01" {} \; | cut -d ":" -f 1 | sort | uniq<br><br>Now if you do require this information inside a python app, I would just do the above in python<br>
<br>filenames = []<br>searchCmd = "find <path_to_dirs_containing_files> -name \"*\" -exec grep -nH \"LF01\" {} \; | cut -d \":\" -f 1 | sort | uniq"<br>searchp = Popen(searchCmd, shell=True, bufsize=4096, stdout=PIPE)<br>
    for line in searchp.stdout:<br>      filenames.append(line.strip())<br><br>Thats my advise anyway, guess you can try some search libraries don't know of any mysql tho, the above will probably be faster than anything else.<br>
<br>Cheers and good luck.<br></div></div><br>