You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Jupyter in VSCode. Several of the twarc functions lead to the entire of the data being printed to the console which makes debugging a pain and generally clogs things up.
An example code that does this.
from twarc.client2 import Twarc2
from twarc.expansions import ensure_flattened
from twarc.expansions import ensure_flattened
twarc = Twarc2(SOME LOGIN INFO)
listOfIds = [SOMEIDS]
for id in listOfIds
search = twarc.liking_users(id, max_results=100)
for page in search:
for profile in ensure_flattened(page):
# Do something with the tweet
allLikes.append({tid:profile['username']})
This code leads to every returned profile being printed in full to the console. Example of the output here.
Hello - it looks ensure_flattened isn't tested on the user profile responses like that endpoint generates - you aren't iterating over tweet objects, but over user profile objects. I wouldn't recommend using it for this particular purpose.
My suggestion is to iterate over the response yourself:
for profile in page["data"]:
# Do something with the user profile
allLikes.append({id: profile['username']})
Maybe it's not clear with the error message, but this is an error that prints out the data for debugging:
Unable to expand dictionary without includes: {'data': ...
the list of users is not something you can "flatten" the same way as tweets. But maybe the error message shouldn't print the entire response because that seems to hide the error.
edsu
changed the title
Code prints all data to console without any print function when using Jupyter
Raise a meaningful error when trying to flatten non-tweet data
Nov 17, 2022
edsu
changed the title
Raise a meaningful error when trying to flatten non-tweet data
Raise a meaningful error when trying to flatten non-tweets
Nov 17, 2022
Using Jupyter in VSCode. Several of the twarc functions lead to the entire of the data being printed to the console which makes debugging a pain and generally clogs things up.
An example code that does this.
This code leads to every returned profile being printed in full to the console. Example of the output here.
https://imgur.com/a/X82V5K9
The text was updated successfully, but these errors were encountered: