Skip to content

Instantly share code, notes, and snippets.

@lppier
Created August 28, 2020 03:10
Show Gist options
  • Select an option

  • Save lppier/b0df08deba95266a1e638d98224bfdec to your computer and use it in GitHub Desktop.

Select an option

Save lppier/b0df08deba95266a1e638d98224bfdec to your computer and use it in GitHub Desktop.
Cycle through all directories recursively and count all the rows in all the xlsx files
import os
total_qns = 0
rootdir = '.'
for subdir, dirs, files in os.walk(rootdir):
for file in files:
path = os.path.join(subdir, file)
print(path)
if path.endswith('.xlsx'):
df = pd.read_excel(path)
total_qns += df.shape[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment