Created
July 25, 2019 05:18
-
-
Save arunkarnann/fe7740e0881c0c251e1ff783c60add1c to your computer and use it in GitHub Desktop.
Merges all txt file the current folder and create a new file with all contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shutil | |
import glob | |
outfilename = "all.txt" | |
with open(outfilename, 'wb') as outfile: | |
for filename in glob.glob('*.txt'): | |
if filename == outfilename: | |
# don't want to copy the output into the output | |
continue | |
with open(filename, 'rb') as readfile: | |
shutil.copyfileobj(readfile, outfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment