Iterating over files of a huge directory
gilles.lenfant at gmail.com
Mon Dec 17 16:28:46 CET 2012
I have googled but did not find an efficient solution to my problem. My customer provides a directory with a huuuuge list of files (flat, potentially 100000+) and I cannot reasonably use os.listdir(this_path) unless creating a big memory footprint.
So I'm looking for an iterator that yields the file names of a directory and does not make a giant list of what's in.
for filename in enumerate_files(some_directory):
# My cooking...
Many thanks by advance.
More information about the Python-list