I am writing a dictionary in a json file and I made a function to read the json and send it to a html file. My problem it's that it's not actually writing the dictionary. I really need help with this, because after a lot of thinking and searching I can't find what I am doing wrong.
I am making the dictionary in a file called queries
dict_scan_data = scan_data.to_dict(orient='records')
data_load ={}
data_load['noscan'] = dict_scan_data
return json.dumps(data_load)
def updateJsonFiles():
f = open('../site/json/data.json', 'w')
f.write(calcProductionAsJSON())
f.close()
# updateJsonFiles()
I made the read function like this:
import json
from queries import calcProductionAsJSON
def GetProductionTotals():
"""
Return the production data as json
"""
f = open('../site/json/data.json', 'r')
data = f.read()
f.close()
return json.dumps(data)
def GetProductionTotalsLive():
"""
Return the production data as json
"""
return calcProductionAsJSON()
And in the html:
<tr ng-repeat="item in data">
<td>{{ item.Masina }}</td>
<td>{{ item.Productie }}</td>
<td>{{ item.Scanned }}</td>
<td>{{ item.Delta }}</td>
</tr>
I am very new to python, so sorry if this question may seem easy or silly