Skip to content

Commit cfc3846

Browse files
committed
Change format of output json
1 parent d260890 commit cfc3846

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tables2json.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ def t2j(df):
4444

4545
def tables2json(tables_dir):
4646
metadata, tables, celltags = get_tables(tables_dir)
47-
all_data = {}
47+
all_data = []
4848
for arxiv_id in metadata:
49-
table = {'metadata': metadata[arxiv_id]}
5049
tabs = []
51-
cts = []
52-
for tab in tables[arxiv_id]:
53-
tabs.append(t2j(tables[arxiv_id][tab]))
54-
for ct in celltags[arxiv_id]:
55-
cts.append(t2j(celltags[arxiv_id][ct]))
56-
table['tables'] = tabs
57-
table['celltags'] = cts
58-
all_data[arxiv_id] = table
50+
for tab in metadata[arxiv_id]:
51+
table = dict(
52+
name=tab,
53+
caption=metadata[arxiv_id][tab],
54+
values=t2j(tables[arxiv_id][tab]),
55+
tags=t2j(celltags[arxiv_id][tab])
56+
)
57+
tabs.append(table)
58+
all_data.append(dict(paper_id=arxiv_id, tables=tabs))
5959
print(json.dumps(all_data))
6060

6161
if __name__ == '__main__': fire.Fire(tables2json)

0 commit comments

Comments
 (0)