Instantly share code, notes, and snippets.

What would you like to do?
Combine freetalk history files
#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:
else :
s = a2.pop()
s += line
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))
map(sys.stdout.write, a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment