Open shaun10 opened 5 years ago
@shaun10 Please provide your code snippet.
entities_df = json_normalize([item.to_params() for item in Account.all(account_object)], sep='_')
Account object is an account object iterated over from the below.
accounts = client.accounts()
@shaun10 That seems wrong.
When you call accounts = client.accounts()
without any arguments, that means you're silently calling Account.all()
anyway, so you don't have to do it again.
https://github.com/twitterdev/twitter-python-ads-sdk/blob/master/twitter_ads/client.py#L89
So doing it again is restricted for the Account? I am trying to use the resource.py to_params
to get all of the account information and attributes.
@shaun10 Why not just do something like:
account_object = client.accounts()
entities_df = json_normalize([item.to_params() for item in account_object], sep='_')
@shaun10 Let me know if you still have a question for this, or I'll close this later.
@smaeda-ks yeah I can do it with the suggested approach but I have to add a conditional statement to the method because I cannot call a generic Object.all() because for Account object all is already called and I cannot re-call the all method.
@shaun10 Sorry, but I don't get your point. Could you elaborate what's your goal here and what's the problem you're trying to solve?
Since with that approach, entities_df
has a list which has all the necessary information you need and I'm wondering why you want to call .all()
again.
So high level I have a method that is called and takes an entity object and then stores all the returned entities in a data frame to produce lookup data for the account. I have many accounts so I call all on every account for a given entity type then store the results in a table. I take the entity object into the method then call .all to get all of the entities back and store them. I have a predefined column list I use to control what columns I store in the data frame. I then take that and save it to a file and store it in a table. The all is pretty much everything here. I just didn't understand why all could be called on PromotedTweet, MediaLibrary, FundingInstrument etc but not on the Account.
I created lookup tables already for most of these data types but it looks like I can't do it for the Account?
Is this normal? There is an all method but getting a trace error.