-
Notifications
You must be signed in to change notification settings - Fork 39
Fix code to download the works of a single author #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
By default `get` returns only the first 25 entries
|
Hi @raffaem! Thanks for noting that the example doesn't return all works of an author and for giving a way to collect all the works. I want to keep the examples section a bit more streamlined though, and avoid every example giving a different handcrafted way to get all the pages from a paginator. The easiest way would be to simply link to say something like: 'this example gives the first 25 works of an author, to get all works see the section on pagination.' Alternatively, you could update the example, but make it a bit more clean. There is no need to write a function in an example, you can get all the works using 2 lines of code. See for example this post. |
I don't understand what those two lines would be. Something like that: would still download just the first page. How do you check the last page was reached? |
|
In the example, every batch will contain 10 records. For every step in the for-loop, you will make a request to OpenAlex for the 10 records in the batch and you will get a response with a page size of 10. So the page will contain all the records from the batch. So there is really no such thing as a 'last page' in the example. There is only the last batch. You can try adding print statements to see what is happening, e.g.: Does this make sense to you? |
I don't understand why we are filtering by Works' OpenAlex IDs when we want to filter by Works' Authors' OpenAlex IDs and we don't know how many works that author published in advance. |
|
How would you rewrite my |
|
Oh sorry, you're totally right. I got confused with a different question and pointed you to the wrong place. What I gave only works if you already have a list of work identifiers. Finding all the works from an author can be done using the basic example from the pagination section: If you want access to the index of the current page for log statements, you wrap the pager in |
|
I like the simplicity of your example @PeterLombaers. I propose to use that example. |
Yes |
Thanks, that was exactly what I needed! |
By default
getreturns only the first 25 entries