Closed Erotemic closed 6 years ago
Just so I understand you correctly, are you asking about the total count of items in "My Library"? Pyzotero doesn't have a specific method for this, but I can certainly add one that will be fast, since that value is returned as a response header.
In answer to your alternative suggestion: Pyzotero will never interact with the local Zotero cache; it's an API client only.
Yes, I believe you understand correctly. I'm interested in the total count of items that would be returned by zot.items
if you do something like this:
items = []
total = zot.num_items() # FIXME: this is number of toplevel items, not all items
start_index = 0
while True:
next_items = zot.items(limit=cfg.limit, start=start_index)
if len(next_items) == 0:
break
items.extend(next_items)
start_index = start_index + len(next_items)
print('reading items = {} / ~{}'.format(start_index, total), file=sys.stderr)
Note that where I use zot.num_items
is where I would want to use zot.count_items
.
OK, v1.3.6, live on PyPI now, has the count_items()
method.
Thanks so much!
In my usage of pyzotero I see that zot.items, seems to return all items in "My Library", but
zot.num_items
, only returns the number of top-level items in the library. I only see one more function that references the number of items and that'szot.num_collectionitems
, which can return the number of items in a collection, but is there / can there be a way to quickly total number of items in "My Library"?Alternatively, is there a way to make pyzotero read from the cache in
$HOME/Zotero/zotero.sqlite
, so thezot.items
call works a bit quicker?