How to convert data from class to list/string

I got data from [api_instance.post_analytics_users_details_query(body)].
But it's class type, and can not convert to csv by using pd.json_normalize() as it's not list type.
Do you know how to convert it class type to list/string type?

Hi,

You can get the string representation using

response = api_instance.post_analytics_users_details_query(body)
response_str = response.__str__()

As it's json format, and I want to use pd.json_normalize() to convert it to csv type.
Do you know how to convert it to list type?

You could use do

response_list = response.__dict__.items()

But this wouldn't yield a very usable list. The best thing you can do is write your own function that extracts the properties you want into a list representation that works for you.

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