DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Mert has posted 1 posts at DZone. View Full User Profile

Join Text Files In Python

08.07.2009
| 8991 views |
  • submit to reddit
        // join contents of text files in current directory

import os
filenames = os.listdir('.')
content = ''
for f in filenames:
    content = content + '\n' + open(f).read()
open('joined_file.txt','wb').write(content)