Skip to content

Instantly share code, notes, and snippets.

@shavidzet
Last active November 22, 2015 14:36
Show Gist options
  • Save shavidzet/21fae8b2c72703c00b5b to your computer and use it in GitHub Desktop.
Save shavidzet/21fae8b2c72703c00b5b to your computer and use it in GitHub Desktop.
The following algorithm help us to handle directory files whole content

The following algorithm help us to handle directory files whole content

just print contents variable where you want.

import os
path = "./data";
contents = ""
for path,dirs,files in os.walk(path):
for fn in files:
with open(os.path.join(path,fn)) as f: contents += f.read()
#print os.path.join(path,fn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment