30 lines
579 B
Python
30 lines
579 B
Python
import sys
|
|
|
|
|
|
def split_line(line):
|
|
spl = line.strip().split(' ')
|
|
cleaned = map(lambda x: x.strip(), (filter(lambda x: x.strip(), spl)))
|
|
return list(cleaned)
|
|
|
|
|
|
def latexify_row(row):
|
|
return ((' & '.join(row)) + r' \\')
|
|
|
|
|
|
lines = sys.stdin.readlines()
|
|
table = list(map(split_line, lines))
|
|
|
|
cols = len(table[0])
|
|
|
|
### Formatting
|
|
|
|
print('\\begin{tabular}{' + ('r ' * cols) + '}')
|
|
|
|
## Head row
|
|
print('\t'
|
|
+ latexify_row(list(map(lambda x: r'\leftcell{' + x + r'}', table[0]))))
|
|
|
|
for row in table[1:]:
|
|
print('\t' + latexify_row(row))
|
|
|
|
print(r'\end{tabular}')
|