#merge text file in folder import glob2 filenames = glob2.glob('*.txt') # list of all .txt files in the directory with open('outfile.txt', 'w') as f: for file in filenames: with open(file) as infile: f.write(infile.read()+'\n')
Search This Blog
Sunday, October 1, 2017
MERGING TEXT FILES OR CSV FILES IN PYTHON
The most useful to be productive and for programing to sost and systemize information from various sources I find merging files together scripts. I used python glob and glob2 projects. To use text files merging is more beneficial since in require less time and PC resources. The necessary files have to be in one folder as well as script. I found many script codes on Stackoverflow using keywords as concatenate, merge files. Merging is simple and fast.