Expandable Fields of Conversation Detail

Hi,

We are trying to extract data for the Conversation Detail by calling the API through Python. While extracting the data we have observed few fields (i.e. arrays) are expandable like the Metrics, Media_endpoint_stats and Flow etc. These are nested arrays and they don't exist all the time. When there aren't nested arrays the values for these fields are "None".

If you look at the below JSON snippet for Media_endpoint_stats array, there is a nested array.

Question - As we are trying to convert the semi structured JSON to a structured CSV file which later is ingested to a table, what is the best way to handle such a scenario using Python for data extraction ?

Conversation_1:
'conversation_id': '43362fa3-33e5-4117-8a72-05a3126a744d'
'media_endpoint_stats': [{'codecs': ['audio/PCMA'],
'discarded_packets': None,
'duplicate_packets': None,
'event_time': datetime.datetime(2022, 5, 25, 0, 54, 45, 597000, tzinfo=tzutc()),
'invalid_packets': None,
'max_latency_ms': 84,
'min_mos': 4.393716549186179,
'min_r_factor': 92.42170715332031,
'overrun_packets': None,
'received_packets': 1576,
'underrun_packets': None},
{'codecs': ['audio/opus'],
'discarded_packets': None,
'duplicate_packets': None,
'event_time': datetime.datetime(2022, 5, 25, 0, 54, 45, 643000, tzinfo=tzutc()),
'invalid_packets': None,
'max_latency_ms': 30,
'min_mos': 4.882312921390206,
'min_r_factor': 92.43939971923828,
'overrun_packets': None,
'received_packets': 1619,
'underrun_packets': None}]

Thanks & Regards,
Vinay

This is expected. Analytics results only contain elements for which data exists. If there's no data for something, it won't exist in the response.

Your code should be tolerant of optional data. What you do in those cases depends entirely on how you're writing your code and what your use case requires for that scenario.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.