Demo entry 6644089

MERGE TEXT FILES IN FOLDER

   

Submitted by anonymous on Oct 01, 2017 at 11:38
Language: Python. Code size: 179 Bytes.

from glob2 import glob

with open('total.txt', 'a') as singleFile:
    for csvFile in glob('*.txt'):
        for line in open(csvFile, 'r'):
           singleFile.write(line)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).