Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AlcibiadesCleinias/56f0cefb558eba9f31adc36247274de9 to your computer and use it in GitHub Desktop.
Save AlcibiadesCleinias/56f0cefb558eba9f31adc36247274de9 to your computer and use it in GitHub Desktop.
import os
from tqdm import tqdm
SUPPORTED_FORMATS = ['py']
directory = './src'
output_file = 'out.txt'
file_paths = [
os.path.join(dirpath, file) for (dirpath, subdirs, files) in os.walk(directory) for file in files
if file.rsplit('.', 1)[-1].lower() in SUPPORTED_FORMATS
]
for file_path in tqdm(file_paths, position=0):
with open(file_path) as f:
file_data = f.read()
with open(output_file, 'a') as f:
f.write(f'\n{file_path}\n' + file_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment