This notebook assumes that the user has a list of unique IDs for bibliographic records within the library software system [Alma](https://knowledge.exlibrisgroup.com/Alma/Product_Documentation/010Alma_Online_Help_(English)/010Getting_Started/010Alma_Introduction/010Alma_Overview).
This notebook assumes that the user has a list of unique IDs for bibliographic records within the library software system [Alma](https://knowledge.exlibrisgroup.com/Alma/Product_Documentation/010Alma_Online_Help_(English)/010Getting_Started/010Alma_Introduction/010Alma_Overview).
In the following code the unique IDs are AC-numbers, which are a special identifier within the [Austrian Library Network](https://www.obvsg.at/). You could also provide other unique IDs like MMS-IDs or barcodes. In that case find and replace the function *by_marc_009()* with one of the other two functions provided by the catalogue submodule: *by_barcode()* or *by_mms_id()*.
In the following code the unique IDs are AC-numbers, which are a special identifier within the [Austrian Library Network](https://www.obvsg.at/). You could also provide other unique IDs like MMS-IDs or barcodes. In that case find and replace the function *by_marc_009()* with one of the other two functions provided by the catalogue submodule: *by_barcode()* or *by_mms_id()*.
In this example the catalogue of the Austrian National Library is the source. We use SRU to fetch the data and python's pandas module to export the data to Excel.
In this example the catalogue of the Austrian National Library is the source. We use SRU to fetch the data and python's pandas module to export the data to Excel.
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Setup
## Setup
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Necessary imports of standard, third party and local modules.
Necessary imports of standard, third party and local modules.
The local modules *almasru* and *marc_extractor* were taken from submodules in [catalogue](https://labs.onb.ac.at/gitlab/labs-team/catalogue/).
The local modules *almasru* and *marc_extractor* were taken from submodules in [catalogue](https://labs.onb.ac.at/gitlab/labs-team/catalogue/).
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
importdatetime
importdatetime
importre
importre
importsys
importsys
fromcollectionsimportOrderedDict
fromcollectionsimportOrderedDict
importpandasaspd
importpandasaspd
importalmasru
fromcatalogue.sruimportalmasru
importmarc_extractor
fromcatalogue.marc_toolsimportmarc_extractor
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Basic setup of almasru for ONB. If you want to fetch the data for a different institution, change the following line.
Basic setup of almasru for ONB. If you want to fetch the data for a different institution, change the following line.
Take note that in the current version *mapping.csv* has no influence on the information inherited from parent records. If you need to change the inherited info, take a look at the function *inherit_from_parent()* and *add_inheritance_to_columns()* in the cells below.
Take note that in the current version *mapping.csv* has no influence on the information inherited from parent records. If you need to change the inherited info, take a look at the function *inherit_from_parent()* and *add_inheritance_to_columns()* in the cells below.
To get an idea of how the mapping works, take a look at the *build_extractor* function in the local *marc_extractor* module.
To get an idea of how the mapping works, take a look at the *build_extractor* function in the local *marc_extractor* module.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
mapping=pd.read_csv('mapping.csv')
mapping=pd.read_csv('mapping.csv')
mapping=mapping.where((pd.notnull(mapping)),None)
mapping=mapping.where((pd.notnull(mapping)),None)
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Check if mapping looks okay, meaning it is adopted correctly in pandas. Show first and last entry for visual control.
Check if mapping looks okay, meaning it is adopted correctly in pandas. Show first and last entry for visual control.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
pd.concat((mapping.iloc[:1],mapping.iloc[-1:]))
pd.concat((mapping.iloc[:1],mapping.iloc[-1:]))
```
```
%% Output
%% Output
MARC controlfield MARC extra selector Liste \
MARC controlfield MARC extra selector Liste \
0 009 None None
0 009 None None
33 AVA _ _ $$d ; AVA _ _ $$i ; AVA _ _ $$j None None
33 AVA _ _ $$d ; AVA _ _ $$i ; AVA _ _ $$j None None
Fetch MARC-XML of both the requested records (potential children) and - if present - of their parent records. Parent records may contain information that is viable for all their children and should be added or appended accordingly. The function *add_inheritance_to_columns()* will add the parent's information to the pandas dataframe.
Fetch MARC-XML of both the requested records (potential children) and - if present - of their parent records. Parent records may contain information that is viable for all their children and should be added or appended accordingly. The function *add_inheritance_to_columns()* will add the parent's information to the pandas dataframe.