Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Combine freetalk history files
#!/usr/bin/python2
#usage: scriptname file1 file2 ...
import sys
import re
def toarray(a):
entrystart = re.compile('[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} \[[^\s]*@[^\s]*\]')
a2 = []
for line in a:
match = entrystart.match(line)
if match is not None:
a2.append(line)
else :
s = a2.pop()
s += line
a2.append(s)
return a2
def filetoarray(s):
f = open(s,'r')
return toarray(f.readlines())
a = []
a = map(filetoarray, sys.argv[1:])
a = [item for sublist in a for item in sublist]
a = list(set(a))
a.sort()
map(sys.stdout.write, a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment