Open dineshmrai opened 1 month ago
Happy to help ☺ Please post your code, so I can run on my side. If possible please state your target? Perhaps a simple API Call can serve your needs.
This is the code. I am a noob in coding and trying to learn and build.
import requests import json import pandas as pd
def print_json_as_table(json_array): df = pd.DataFrame(json_array) print(df)
def combine_json_arrays(json_array1, json_array2): combined_json_array = [] for obj1 in json_array1: for obj2 in json_array2: if obj1["House"] == obj2["House"]: combined_obj = {obj1, obj2} combined_json_array.append(combined_obj) return combined_json_array
domainName = "https://api.vedastro.org" timeLocation = "Location/Kanpur,UttarPradesh,India/Time/17:15/19/11/2002/+05:30"
url = f'{domainName}/Calculate/AllHousePlanetsInHouseBasedOnSign/{timeLocation}' rawData = requests.get(url).json()["Payload"] allPlanetHousePositionsBasedOnSignList = next(iter(rawData.values()))
url2 = f'{domainName}/Calculate/AllHouseSignName/{timeLocation}' rawData2 = requests.get(url2).json()["Payload"]
allHouseSignNameList = next(iter(rawData2.values()))
combined_json_array = combine_json_arrays(allPlanetHousePositionsBasedOnSignList, allHouseSignNameList)
print_json_as_table(combined_json_array)
@dineshmrai apologies for the late reply 🙏 I've completely stopped touching the Python version almost 6 months. So unfortunately, I sincerely do not know how to solve the issue your facing. 😅 If you stumbled upon the solution please feel free to make PR 🙏😊
I am getting the below errors" Traceback (most recent call last): File "D:\Project\VedAstro.Python\demo_code_from_api_builder.py", line 13, in
calcResult = Calculate.HousePlanetIsIn(time, planetName)
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Calculate' has no attribute 'HousePlanetIsIn'""
And after debugging below :
AllHousePlanetsInHouseBasedOnSign response: { "Status": "Pass", "Payload": { "AllHousePlanetsInHouseBasedOnSign": "System.Collections.Generic.Dictionary
2[VedAstro.Library.HouseName,System.Collections.Generic.List
1[VedAstro.Library.PlanetName]]" } } AllHouseSignName response: { "Status": "Fail", "Payload": "Calculator method not found!" } Failed to get AllHouseSignName data: {'Status': 'Fail', 'Payload': 'Calculator method not found!'} No data to combine.