-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlablegen.py
38 lines (28 loc) · 821 Bytes
/
lablegen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
__version__ = "0.2.0"
__author__ = "Social Mean"
import pyperclip
def table_generator(dic, clip=False):
col_count = len(dic)
row_count = len(dic[list(dic.keys())[0]])
latex_table_str = """\\begin{table}[H]
\\centering
\\begin{tabular}{""" + "c" * col_count + """}
\\hline\n"""
for key in dic:
latex_table_str += key + " &"
latex_table_str = latex_table_str[0:-1]
latex_table_str += """\\\\
\\hline\n"""
for i in range(row_count):
for key in dic:
latex_table_str += str(dic[key][i]) + " &"
latex_table_str = latex_table_str[0:-1]
latex_table_str += "\\\\\n"
latex_table_str += """\\hline
\\end{tabular}
\\caption{}
\\label{}
\\end{table}"""
if clip:
pyperclip.copy(latex_table_str)
return latex_table_str