2 Convert word table to various other formats.
4 Needs tabulate (https://pypi.python.org/pypi/tabulate).
6 Usage: python wordtable.py actions.txt > actions.rst
10 from tabulate import tabulate
13 def tabledata(data, rows=10):
14 padding = rows - (len(data) % rows)
15 values = list(data) + [None] * padding
16 for row in range(rows):
17 yield [values[idx] for idx in range(row, len(values), rows)]
20 def writetable(words, formats):
21 table = list(tabledata(words))
22 print ".. Autogenerated by wordtable.py -- do not edit!"
25 output = tabulate(table, tablefmt=fmt)
30 for line in output.split("\n"):
34 if __name__ == "__main__":
38 for word in fileinput.input():
39 words.append(word.strip())
41 writetable(words, formats=['html', 'latex'])