Managing early-modern “island” works in ZOTERO
Challenges of large-scale library management in Zotero
A vital aspect of my research is the analysis of thousands of publication metadata manually and automatically imported to a Zotero library. As the data come from different digital sources in different languages, I faced two main challenges when first creating my collection:
- The tags adopted from the various libraries followed different bibliographic guidelines and often consisted in long strings that displayed the hierarchies of the categories used.
- Early-modern item titles were inconsistently transcribed. Some institutions had normalised excessive capitalisation or even normalised old-fashioned spelling. The usage of colons and commas in titles was equally inconsistent. As a consequence, it was not always easy to identify duplicates even with Zotero’s in-built duplicate finder.
This is why I needed to manipulate large amounts of tags and titles in an automated manner.
Cleaning tags with PyZotero
In order to better handle the imported tags, I split long tag string by regular expression and replaced them for individual tags. Here the Zotero API accessed via PyZotero proved very helpful. My first attempts to replace one long tag by several shorter tags failed, however, because Zotero would not allow me to update the very same item repeatedly within a few seconds.
After intial work-arounds using the sleep()
function, I re-structured my script to add only the first new tag to each item before repeating the process on the second new tag etc. As this script, however, calls each item in the library and checks all its tags, retry limits are likely to be exceeded if libaries are large. In Zotero, the relevant error notification is:
ConnectionError: HTTPSConnectionPool(host='api.zotero.org', port=443): Max retries exceeded with url: /groups/[libraryID]/collections/[collectionID]/items?limit=100&start=8900 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x000002605EDD4408>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
In these cases, I recommend restricting the loop to only a few repetitions at a time and re-running the script over several days.
My new script is available in my “Digital History” repository on GITHUB and can be adapted to other use cases. Deleting the replaced tags is deliberately not part of this script but best carried out separately. PyZotero includes a function to batch-delete tags, but the Zotero “tag selector” also makes it very easy to delete unwanted tags by hand. The tag selector is to be found in the bottom-left corner of the Zotero stand-alone client. Apart from the convenient deletion of tags, the tag selector permits the renaming and (temporary) highlighting of tags in selected collections.
Locally editing metadata with Javascript
Inconsistencies in my item titles were cleaned with a Javascript code run directly in the “Run Javascript” console of the Zotero stand-alone client. This EditTitles_Zotero.js script is also available on GITHUB. The screenshot on the left shows how the Javascript console is opened in the German-language version of Zotero. The details of client coding with the Javascript API are explained in the Zotero documentation. User issues concerning Javascript are discussed in various threads in the Zotero Forums and – more extensively – on the Zotero development mailing list. The Zotero developers and experienced users are always eager to help.
OpenEdition suggests that you cite this post as follows:
Monika Barget (March 9, 2021). Managing early-modern “island” works in ZOTERO. INSULAE. Retrieved November 3, 2024 from https://doi.org/10.58079/qd8u