Skip to content

Instantly share code, notes, and snippets.

@henkjanverkerk
Last active October 19, 2016 13:46
Show Gist options
  • Save henkjanverkerk/e8a1122a697ee44105ecce091f13ed9c to your computer and use it in GitHub Desktop.
Save henkjanverkerk/e8a1122a697ee44105ecce091f13ed9c to your computer and use it in GitHub Desktop.
Simple merger for flat files
# Needed this for merging a couple of log files into one file under conditions:
# - only files of type .log needed to be merged
# - only line starting with 'RLS' needed to be merged
import os
g = open('total.txt','a')
for file in os.listdir('.'):
if file.endswith('.log'):
f = open(file,'r')
for line in f:
if line.startswith('RLS'):
g.write(line)
f.close()
g.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment