###################
## ##
## ##
###### ##
## ######
## ##
## ##
###################
When a table of contents should be added to enrich a bibliographic record, this script automates the process. It uploads the pdf-file to a public server and adds a 856 field to the bibliographic record in Alma, generating a link in the discovery system.
As soon as the scanned pdf-file (named barcode.pdf
, where barcode
is the actual barcode ot the bibliographic item) is placed in a folder on a computer or on Sharepoint, the script will upload it to a public server, rename it to mms-id.pdf
(where mms-id
is the NZ MMS-ID of the record) and add a field 856 to the MARC21 record in Alma.
The following python modules are required for the script to run (a requirements.txt
is included):
- argparse
- datetime
- dotenv
- json
- lxml
- paramiko
- os
- re
- smtplib
- ssl
- sys
- Download all files.
- Create empty folders named
log
,temp
andxml
in the root directory. - Rename the file
.env.example
to.env
and submit your credentials inside the quotes:
API_URL=""
API_KEY=""
EMAIL_PASS=""
FTP_URL=""
FTP_USER=""
FTP_PASS=""
- Update some values in
data/config.json
:- Update
{"email": {"from": ""}}
to the address which will send the enrichment report - Update
{"email": {"to": ""}}
to the address which will receive the enrichment report - Update
{"path": {"r": ""}}
to the remote path on your ftp server - Update
{"library": {}}
to keys holding the parameters you will use with the command line tool (-l
or--lib
) and values holding the corresponding subfolders on the remote server
- Update
- This is how to run the script from the command line on MacOS (replace
toc/BM2064150.pdf
andwin
with your values):
python3 enrich.py -f toc/BM2064150.pdf -l win
- This is how to run the script from the command line on Windows (replace
toc/BM2064150.pdf
andwin
with your values):
python enrich.py -f toc/BM2064150.pdf -l win
- The relative path to the pdf-file including its name must be suplied by passing a parameter
-f
or--file
. - The code for the library for the pdf-file must be suplied by passing a parameter
-l
or--lib
.
- To show the help message on MacOS enter:
python3 enrich.py -h
- To show the help message on Windows enter:
python enrich.py -h
If this doesn't help, feel free to contact me.
This script was created by Rhodijn (zolo) for ZHAW HSB inside the 2025 CAS Data Management and Information Technologies at the University of Zurich.
- 1.0
- Initial Release (2025-06-17)
This project is licensed under the Apache 2.0 License - see the LICENSE.md file for details.