Feb-27-2017, 09:07 PM
For learning purposes, I am trying to create a script to:
-read a list of keywords and store in a array (done)
-list files in a dir tree (done)
-read each file (some big files 10GB+) and search for each keyword in my array (DANG).
so heres a piece of my code:
I just dont know how to proceed (2+ hours of google right now).
ps: I know I can use re.search to make case-insensitive searchs, but I THINK this can consume more resources than lowercase all the files contents.
Thank you!

-read a list of keywords and store in a array (done)
-list files in a dir tree (done)
-read each file (some big files 10GB+) and search for each keyword in my array (DANG).
so heres a piece of my code:
def search_files(keywords_array,lista): for i_lista in lista: arquivo = open(i_lista,"r") str_buffer = mmap.mmap(arquivo.fileno(), 0, access=mmap.ACCESS_READ) print(str(str_buffer)) for i_keywords in keywords_array: if str_buffer.find(i_keywords.lower()) != -1: print(color.BOLD + "Bingo! : " + color.END + color.RED + i_keywords + color.END + " : " + i_lista)everything works fine, UNTIL I need to lowercase the file contents (str_buffer / mmap) to search with my (lowercase) keywords in array.
I just dont know how to proceed (2+ hours of google right now).
ps: I know I can use re.search to make case-insensitive searchs, but I THINK this can consume more resources than lowercase all the files contents.
Thank you!
