#!/usr/bin/env python import re def convert(line, head = False): pat = re.compile(r'([$]\S*)') line = pat.sub(r'\1', line) row = [x.strip() for x in line.split('|')] fmt = ' %s%s' if head: fmt = fmt.replace('td', 'th') print fmt % tuple(row) f = file('parameters.txt') print '' convert(f.readline(), head = True) f.readline() for line in f: convert(line) print '
'