I am new to python,but I have managed to write a simple code to generate json data to html format through json2html module. json2html.convert(json=input),here when I pass the json node it is working file,but I should pass a json file created from my application as input to json2html to generate the html table format.How could I pass any json file as input to convert the file to html table ?
1 Answer
You can try using json2table module, at least I did like that. The following code creates a html file with all json data table-structured.
from json2table import *
import json
data = open('YOURFILE.json','r')
jsonFile = data.read()
foo = json.loads(jsonFile)
build_dir = "LEFT_TO_RIGHT"
table_attr = {"style" : "width:100%", "class" : "table table-striped"}
html = convert(foo, build_direction=build_dir,table_attributes=table_attr)
with open("YOURFILE.html", "w") as ht:
ht.write(html)