diff --git a/Demand_forcasting/forcasting2.py b/Demand_forcasting/forcasting2.py index 1dbc58e..4e73816 100644 --- a/Demand_forcasting/forcasting2.py +++ b/Demand_forcasting/forcasting2.py @@ -231,21 +231,24 @@ def day(Num,get_url,get_url_token,post_url,post_url_token): print(result) result.to_json('forcast.json', orient="records") + with open('forcast.json', 'r') as json_file: json_load = json.load(json_file) #url = "https://demo.bizgaze.app/apis/v4/bizgaze/integrations/demandforecast/saveforecast/List" - url=post_url + url=post_url - payload = json.dumps(json_load)#.replace("]", "").replace("[", "") + payload = json.dumps(json_load)#.replace("]", "").replace("[", "") + print(payload) #print(payload) - headers = { + headers = { #'Authorization': 'stat 263162e61f084d3392f162eb7ec39b2c',#demo 'Authorization': post_url_token,#test - #'Content-Type': 'application/json' - } - response = requests.request("POST", url, headers=headers, data=payload) - print("##############################################################") - print(response.text) + 'Content-Type': 'application/json' + } + response = requests.request("POST", url, headers=headers, data=payload) + # print("##############################################################") + print(response.text) + return 'done' @@ -488,44 +491,20 @@ def month(Num,get_url,get_url_token,post_url,post_url_token): with open('forcast.json', 'r') as json_file: json_load = json.load(json_file) #url = "https://demo.bizgaze.app/apis/v4/bizgaze/integrations/demandforecast/saveforecast/List" - url=post_url + url=post_url - payload = json.dumps(json_load)#.replace("]", "").replace("[", "") + payload = json.dumps(json_load)#.replace("]", "").replace("[", "") + print(payload) #print(payload) - headers = { + headers = { #'Authorization': 'stat 263162e61f084d3392f162eb7ec39b2c',#demo 'Authorization': post_url_token,#test - # 'Content-Type': 'application/json' - } - response = requests.request("POST", url, headers=headers, data=payload) + 'Content-Type': 'application/json' + } + response = requests.request("POST", url, headers=headers, data=payload) # print("##############################################################") - # print(response.text) - - # filePath='path.csv' + print(response.text) - - # if os.path.exists(filePath): - # print('file exist') - # #userdata = pd.DataFrame(data) - # result.to_csv('path.csv', mode='a',index=False, header=False) - - # else: - # print("file as it doesn't exists") - # #result = pd.DataFrame(data) - # result.to_csv('path.csv', index=False) - - - - # result=pd.read_csv('path.csv') - # result.to_json('forcast.json', orient="records") - # import json - - # # open the JSON file and read its contents - # with open(r'forcast.json', 'r') as f: - # json_data = json.load(f) - - # print the JSON data - #print(json_data) #output={"response":"success","result":json_data} #print(output)