#1092 Problem with parsing data

Rafay Ahmed Wed 6 Dec 2023


I'm currently experiencing an issue parsing data received from SkySpark using the pyhaystack library. Could you please assist me in figuring out how to convert this data into JSON?

Here's an example of the data:

@p:tfsSmartBuildings:r:2c0726e2-d189496d "West Hills schedule",M,<<
>>,"Los_Angeles",2023-12-06T05:00:00-08:00 Los_Angeles,"ok",M,"West Hills schedule",F,M,"Bool",@p:tfsSmartBuildings:r:2b8fba89-a349178e "West Hills, 22801 Roscoe Blvd",M,T,2023-12-05T05:42:59.486Z

I'm specifically interested in extracting the "schedule" and "siteRef" from this Zinc-formatted data. I've attempted various methods such as using hszinc.parse, but none have been successful.

Thank you for your assistance.

Rafay Ahmed Thu 7 Dec 2023

Currently, I've implemented a temporary solution by custom parsing as follows:

def getScheduleData(zinc_data):

result = []
start_index = zinc_data.find("<<")
end_index = zinc_data.find(">>")
if start_index > -1 and end_index > -1:
    zinc_data = zinc_data[start_index:end_index]
    lines = zinc_data.split("\n", 1)
    zinc_data = lines[1]
    zinc_data = hszinc.parse(zinc_data)
    for row in zinc_data:
        dictObject = dataDictionary()
        for val in row:
            dictObject.add(val, str(row[val]))
return result

However, a more robust solution would be appreciated if anyone could provide assistance.

Thank you.

Login or Signup to reply.