With your input this returns: [200, 20, 0, 13050] so it's not what you want, but maybe it can be a starting point for you:
from re import findall txt = """\ test test test description (100-10-0, 6700 test) test test test description (100-10-0, 6350 test)""" lines = txt.split("\n") res = [map(int, findall("[0-9]+", line)) for line in lines] print map(sum, zip(*res)) Maybe izip and imap can be useful too. lines can be a file object too. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list