Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LOD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labs-team
LOD
Commits
9fe81183
Commit
9fe81183
authored
3 months ago
by
Georg Petz
Browse files
Options
Downloads
Patches
Plain Diff
Add method to extract signature with AC
parent
090d82bc
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Signature.ipynb
+66
-13
66 additions, 13 deletions
Signature.ipynb
with
66 additions
and
13 deletions
Signature.ipynb
+
66
−
13
View file @
9fe81183
...
@@ -2,28 +2,30 @@
...
@@ -2,28 +2,30 @@
"cells": [
"cells": [
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1,
"metadata": {
"metadata": {
"ExecuteTime": {
"ExecuteTime": {
"end_time": "2025-03-20T10:58:00.457437Z",
"end_time": "2025-03-20T10:58:00.457437Z",
"start_time": "2025-03-20T10:58:00.125731Z"
"start_time": "2025-03-20T10:58:00.125731Z"
}
}
},
},
"outputs": [],
"source": [
"source": [
"from lxml import etree\n",
"from lxml import etree\n",
"import requests\n",
"import requests\n",
"import pandas as pd"
"import pandas as pd"
],
]
"outputs": [],
"execution_count": 1
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 2,
"metadata": {
"metadata": {
"ExecuteTime": {
"ExecuteTime": {
"end_time": "2025-03-20T12:29:45.828245Z",
"end_time": "2025-03-20T12:29:45.828245Z",
"start_time": "2025-03-20T12:29:45.824291Z"
"start_time": "2025-03-20T12:29:45.824291Z"
}
}
},
},
"outputs": [],
"source": [
"source": [
"def getSignature(barcode):\n",
"def getSignature(barcode):\n",
" cont=requests.get('https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.barcode=%2BZ' + barcode + '&startRecord=0&maximumRecords=1&operation=searchRetrieve&recordSchema=marcxml').content\n",
" cont=requests.get('https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.barcode=%2BZ' + barcode + '&startRecord=0&maximumRecords=1&operation=searchRetrieve&recordSchema=marcxml').content\n",
...
@@ -36,39 +38,90 @@
...
@@ -36,39 +38,90 @@
" xpath = '/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=\\'AVA\\'][marc21:subfield[@code=\\'b\\']=\\'{}\\']/marc21:subfield[@code=\\'d\\']/text()'\n",
" xpath = '/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=\\'AVA\\'][marc21:subfield[@code=\\'b\\']=\\'{}\\']/marc21:subfield[@code=\\'d\\']/text()'\n",
" signature = e.xpath(xpath.format('ZALT'), namespaces=namespaces)\n",
" signature = e.xpath(xpath.format('ZALT'), namespaces=namespaces)\n",
" return signature"
" return signature"
],
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-20T12:29:45.828245Z",
"start_time": "2025-03-20T12:29:45.824291Z"
}
},
"outputs": [],
"outputs": [],
"execution_count": 21
"source": [
"def getSignatureAC(ac):\n",
" req= 'https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.local_control_field_009=' + ac + '&operation=searchRetrieve'\n",
" print(req)\n",
" cont=requests.get(req).content\n",
" e = etree.XML(cont)\n",
" namespaces = {\n",
" 'srw': 'http://www.loc.gov/zing/srw/',\n",
" 'marc21': 'http://www.loc.gov/MARC21/slim'\n",
" }\n",
" location = \"ZALT\"\n",
" xpath = '/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=\\'AVA\\'][marc21:subfield[@code=\\'b\\']=\\'{}\\']/marc21:subfield[@code=\\'d\\']/text()'\n",
" signature = e.xpath(xpath.format('ZHAN'), namespaces=namespaces)\n",
" return signature"
]
},
},
{
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"metadata": {
"ExecuteTime": {
"ExecuteTime": {
"end_time": "2025-03-20T12:29:53.843004Z",
"end_time": "2025-03-20T12:29:53.843004Z",
"start_time": "2025-03-20T12:29:48.334721Z"
"start_time": "2025-03-20T12:29:48.334721Z"
}
}
},
},
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['2723-A']\n"
]
}
],
"source": [
"source": [
"sig = getSignature(\"136482208\")\n",
"sig = getSignature(\"136482208\")\n",
"print(sig)"
"print(sig)"
],
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"['2723-A']\n"
"https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.local_control_field_009=AC14251814&operation=searchRetrieve\n"
]
},
{
"data": {
"text/plain": [
"['Cod. Ser. n. 14767']"
]
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
}
],
],
"execution_count": 22
"source": [
"getSignatureAC(\"AC14251814\")"
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {},
"source": [],
"outputs": [],
"outputs": [],
"
execution_count": null
"
source": []
}
}
],
],
"metadata": {
"metadata": {
...
@@ -87,9 +140,9 @@
...
@@ -87,9 +140,9 @@
"name": "python",
"name": "python",
"nbconvert_exporter": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"pygments_lexer": "ipython3",
"version": "3.
6.7
"
"version": "3.
10.16
"
}
}
},
},
"nbformat": 4,
"nbformat": 4,
"nbformat_minor":
1
"nbformat_minor":
4
}
}
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
from
lxml
import
etree
from
lxml
import
etree
import
requests
import
requests
import
pandas
as
pd
import
pandas
as
pd
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
def
getSignature
(
barcode
):
def
getSignature
(
barcode
):
cont
=
requests
.
get
(
'
https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.barcode=%2BZ
'
+
barcode
+
'
&startRecord=0&maximumRecords=1&operation=searchRetrieve&recordSchema=marcxml
'
).
content
cont
=
requests
.
get
(
'
https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.barcode=%2BZ
'
+
barcode
+
'
&startRecord=0&maximumRecords=1&operation=searchRetrieve&recordSchema=marcxml
'
).
content
e
=
etree
.
XML
(
cont
)
e
=
etree
.
XML
(
cont
)
namespaces
=
{
namespaces
=
{
'
srw
'
:
'
http://www.loc.gov/zing/srw/
'
,
'
srw
'
:
'
http://www.loc.gov/zing/srw/
'
,
'
marc21
'
:
'
http://www.loc.gov/MARC21/slim
'
'
marc21
'
:
'
http://www.loc.gov/MARC21/slim
'
}
}
location
=
"
ZALT
"
location
=
"
ZALT
"
xpath
=
'
/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=
\'
AVA
\'
][marc21:subfield[@code=
\'
b
\'
]=
\'
{}
\'
]/marc21:subfield[@code=
\'
d
\'
]/text()
'
xpath
=
'
/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=
\'
AVA
\'
][marc21:subfield[@code=
\'
b
\'
]=
\'
{}
\'
]/marc21:subfield[@code=
\'
d
\'
]/text()
'
signature
=
e
.
xpath
(
xpath
.
format
(
'
ZALT
'
),
namespaces
=
namespaces
)
signature
=
e
.
xpath
(
xpath
.
format
(
'
ZALT
'
),
namespaces
=
namespaces
)
return
signature
return
signature
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
def
getSignatureAC
(
ac
):
req
=
'
https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.local_control_field_009=
'
+
ac
+
'
&operation=searchRetrieve
'
print
(
req
)
cont
=
requests
.
get
(
req
).
content
e
=
etree
.
XML
(
cont
)
namespaces
=
{
'
srw
'
:
'
http://www.loc.gov/zing/srw/
'
,
'
marc21
'
:
'
http://www.loc.gov/MARC21/slim
'
}
location
=
"
ZALT
"
xpath
=
'
/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=
\'
AVA
\'
][marc21:subfield[@code=
\'
b
\'
]=
\'
{}
\'
]/marc21:subfield[@code=
\'
d
\'
]/text()
'
signature
=
e
.
xpath
(
xpath
.
format
(
'
ZHAN
'
),
namespaces
=
namespaces
)
return
signature
```
%% Cell type:code id: tags:
```
python
sig
=
getSignature
(
"
136482208
"
)
sig
=
getSignature
(
"
136482208
"
)
print
(
sig
)
print
(
sig
)
```
```
%% Output
%% Output
['2723-A']
['2723-A']
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
getSignatureAC
(
"
AC14251814
"
)
```
%% Output
https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.local_control_field_009=AC14251814&operation=searchRetrieve
['Cod. Ser. n. 14767']
%% Cell type:code id: tags:
```
python
```
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment