Skip to content

Instantly share code, notes, and snippets.

@denkiwakame
Last active August 29, 2015 14:23
Show Gist options
  • Save denkiwakame/20472b5700164d3c8931 to your computer and use it in GitHub Desktop.
Save denkiwakame/20472b5700164d3c8931 to your computer and use it in GitHub Desktop.
grep filepath recursively
import os
from fnmatch import fnmatch
def get_fpath_list(dirpath, ext="*.xlsx"):
fpath_list = []
for root, dir_list, fname_list in os.walk(dirpath):
fpath_list.extend([ os.path.join(root,fname) for fname in fname_list if fnmatch(fname, ext)])
return fpath_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment