Skip to content

Instantly share code, notes, and snippets.

@ratmcu
Last active September 18, 2019 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ratmcu/23353460d01c566a89efe6c81036bbd2 to your computer and use it in GitHub Desktop.
Save ratmcu/23353460d01c566a89efe6c81036bbd2 to your computer and use it in GitHub Desktop.
generator to list file paths of files with the same extension. using os.walk
import os
extension = '.csv'
tree = os.walk('./dataset')
paths = sorted([os.path.join(f[0], name) for f in tree if len(f[2])!=0 for name in f[2] if os.path.splitext(name)[-1] == '.csv'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment