Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from lxml import etree\n",
"import requests\n",
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To get the MMS ID for a given barcode, get the metadata via `https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.barcode=<barcode>startRecord=0&maximumRecords=1&operation=searchRetrieve&recordSchema=dc` and extract the MMS ID with `/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordIdentifier/text()`.\n",
"\n",
"Metadata in Dublin Core can be obtained via SRU.\n",
"\n",
"Linked Data from ALMA (library management system) can be retrieved in \n",
"\n",
"* BIBFRAME via `https://open-na.hosted.exlibrisgroup.com/alma/<institution code>/bf/entity/instance/<mms id>`\n",
"* JSON-LD via `https://open-na.hosted.exlibrisgroup.com/alma/<institution code>/bibs/<mms_id>.jsonld`\n",
"* RDA/RDF via `https://open-na.hosted.exlibrisgroup.com/alma/<institution code>/rda/entity/manifestation/<mms id>.rdf`\n",
"\n",
"For a Network Zone MMS ID the institution code is 43ACC_NETWORK and for the Institution MMS ID it is 43ACC_ONB.\n",
"\n",
"The following xpath `/rdf:RDF/bf:Instance/bf:hasItem/bf:Item/bf:electronicLocator/rdfs:Resource/bflc:locator/@rdf:resource` selects URLs of the Viewer. We use the + sign (URL encoded %2B) to spilt the URL in order to extract the Barcode."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def getMMS_ID(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=dc').content\n",
" e = etree.XML(cont)\n",
" namespaces = {\n",
" 'srw': 'http://www.loc.gov/zing/srw/'\n",
" }\n",
" result = e.xpath('/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordIdentifier/text()', namespaces=namespaces)\n",
" return result[0]\n",
"\n",
"def getDCData(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=dc').content\n",
" e = etree.XML(cont)\n",
" namespaces = {\n",
" 'srw': 'http://www.loc.gov/zing/srw/',\n",
" 'srw_dc': 'info:srw/schema/1/dc-schema',\n",
" 'dc': 'http://purl.org/dc/elements/1.1/'\n",
" }\n",
" xpath = '/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/srw_dc:dc/dc:{}/text()'\n",
" \n",
" titleResult = e.xpath(xpath.format('title'), namespaces=namespaces)\n",
" title = \"; \".join(titleResult) if titleResult else ''\n",
" \n",
" contributorResult = e.xpath(xpath.format('contributor'), namespaces=namespaces)\n",
" contributor = \"; \".join(contributorResult) if contributorResult else ''\n",
" \n",
" dateResult = e.xpath(xpath.format('date'), namespaces=namespaces)\n",
" date = \"; \".join(dateResult) if dateResult else ''\n",
" print([title, contributor, date])\n",
" return [title, contributor, date]\n",
"\n",
"def getLinksAndBarcodes(local_mms_id):\n",
" cont=requests.get('https://open-na.hosted.exlibrisgroup.com/alma/43ACC_ONB/bf/entity/instance/' + local_mms_id).content\n",
" e = etree.XML(cont)\n",
" namespaces = {\n",
" 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n",
" 'bf': 'http://id.loc.gov/ontologies/bibframe/',\n",
" 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#',\n",
" 'bflc': 'http://id.loc.gov/ontologies/bflc/'\n",
" }\n",
" result = e.xpath('/rdf:RDF/bf:Instance/bf:hasItem/bf:Item/bf:electronicLocator/rdfs:Resource/bflc:locator/@rdf:resource', namespaces=namespaces)\n",
" barcodes = []\n",
" for link in result:\n",
" splits = link.split('%2B')\n",
" if len(splits) >= 2:\n",
" barcodes.append('+' + link.split('%2B')[1])\n",
" print(local_mms_id + ': ' + \", \".join(barcodes))\n",
" linksJoined = \", \".join(result)\n",
" barcodesJoined = \", \".join(barcodes)\n",
" #returns a list with URLs and Barcodes\n",
" return [linksJoined, barcodesJoined]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Vorstellung der vornehmsten Völkerschaften der Welt nach ihrer Abstammung, Ausbreitung und Sprachen', 'Breitenbauch, Georg-August vonaut', '1786']\n",
"['Vorstellung der vornehmsten Völkerschaften der Welt nach ihrer Abstammung, Ausbreitung und Sprachen', 'Breitenbauch, Georg-August vonaut', '1786']\n"
]
}
],
"source": [
"dc = getDCData(str(178966306))\n",
"print(dc)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Identifier</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Z98085705</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Z6987270X</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Z97787406</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Identifier\n",
"5 Z98085705\n",
"8 Z6987270X\n",
"2 Z97787406"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_excel('exampleBarcodes.xlsx')\n",
"df_sample = df.sample(3).copy()\n",
"df_sample"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Sammlung der besten Reisebeschreibungen', '', '1784']\n",
"['Sammlung der besten Reisebeschreibungen', '', '1784']\n",
"['Geschichte der Reisen die seit Cook an der Nordwest- und Nordost-Küste von Amerika und in dem nördlichsten Amerika selbst von Meares, Dixon, Portlock, Coxe, Long u. a. m. unternommen worden sind Mit vielen Karten und Kupfern', 'Forster, Georg1754-1794(DE-588)118534416edtO:H; Dixon, George1755-1800(DE-588)130525294ctbO:H; Long, JohnctbO:H; Meares, John1756-1809(DE-588)121248275ctbO:H; Portlock, Nathaniel1748-1817(DE-588)133848531ctbO:H; Portlock, NathanielautO:800O:H; Forster, [Johann] GeorgautAdamO:806O:H; Vossische BuchhandlungBerlin(DE-588)64386-5pblO:H', '1792']\n",
"['Sammlung der besten Reisebeschreibungen', 'Traßler, Joseph Georg1759-1816(DE-588)129262358prt', '1784']\n",
"['Sammlung der besten Reisebeschreibungen', '', '1784']\n",
"['Sammlung der besten Reisebeschreibungen', '', '1784']\n",
"['Beschreibung der äussern und innern Merkwürdigkeiten der Königlichen Schlösser in Berlin, Charlottenburg, Schönhausen in und bey Potsdam', 'Rumpf, Friedrichaut', '1794']\n",
"[\"Neues Elementarwerk für die niedern Klassen lateinischer Schulen und Gymnasien nach einem zusammenhängenden und auf die Lesung klassischer Autoren in den obern Klassen, wie auch auf die übrigen Vorerkenntnisse künftiger Studirenden gründlich vorbereitenden Plane; <<M. J. E. Fabri's>> Elementargeographie; M. J. E. Fabri's Elementargeographie; Fabri's Elementargeographie; M. J. E. Fabri's Elementargeographie; zweiten Zweiter\", 'Fabri, Johann Ernst1755-1825(DE-588)11536028Xaut; Gebauer, Johann Jakobpbl', '1790']\n",
"[\"Neues Elementarwerk für die niedern Klassen lateinischer Schulen und Gymnasien nach einem zusammenhängenden und auf die Lesung klassischer Autoren in den obern Klassen, wie auch auf die übrigen Vorerkenntnisse künftiger Studirenden gründlich vorbereitenden Plane; <<M. J. E. Fabri's>> Elementargeographie; M. J. E. Fabri's Elementargeographie; Fabri's Elementargeographie; M. J. E. Fabri's Elementargeographie; zweiten Kursus\", 'Fabri, Johann Ernst1755-1825(DE-588)11536028Xaut; Gebauer, Johann Jakobpbl', '1790']\n"
]
}
],
"source": [
"df[['Titel', 'Autor', 'Erscheinungsjahr']] = df.apply(lambda row: getDCData(str(row['Identifier'])[1:]), axis=1, result_type='expand')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Identifier</th>\n",
" <th>Titel</th>\n",
" <th>Autor</th>\n",
" <th>Erscheinungsjahr</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Z164418102</td>\n",
" <td>Sammlung der besten Reisebeschreibungen</td>\n",
" <td></td>\n",
" <td>1784</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Z98085808</td>\n",
" <td>Sammlung der besten Reisebeschreibungen</td>\n",
" <td></td>\n",
" <td>1784</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Z97787406</td>\n",
" <td>Geschichte der Reisen die seit Cook an der Nor...</td>\n",
" <td>Forster, Georg1754-1794(DE-588)118534416edtO:H...</td>\n",
" <td>1792</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Z198357107</td>\n",
" <td>Sammlung der besten Reisebeschreibungen</td>\n",
" <td>Traßler, Joseph Georg1759-1816(DE-588)12926235...</td>\n",
" <td>1784</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Z16441800X</td>\n",
" <td>Sammlung der besten Reisebeschreibungen</td>\n",
" <td></td>\n",
" <td>1784</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Z98085705</td>\n",
" <td>Sammlung der besten Reisebeschreibungen</td>\n",
" <td></td>\n",
" <td>1784</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Z167356806</td>\n",
" <td>Beschreibung der äussern und innern Merkwürdig...</td>\n",
" <td>Rumpf, Friedrichaut</td>\n",
" <td>1794</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Z69872607</td>\n",
" <td>Neues Elementarwerk für die niedern Klassen la...</td>\n",
" <td>Fabri, Johann Ernst1755-1825(DE-588)11536028Xa...</td>\n",
" <td>1790</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Z6987270X</td>\n",
" <td>Neues Elementarwerk für die niedern Klassen la...</td>\n",
" <td>Fabri, Johann Ernst1755-1825(DE-588)11536028Xa...</td>\n",
" <td>1790</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Identifier Titel \\\n",
"0 Z164418102 Sammlung der besten Reisebeschreibungen \n",
"1 Z98085808 Sammlung der besten Reisebeschreibungen \n",
"2 Z97787406 Geschichte der Reisen die seit Cook an der Nor... \n",
"3 Z198357107 Sammlung der besten Reisebeschreibungen \n",
"4 Z16441800X Sammlung der besten Reisebeschreibungen \n",
"5 Z98085705 Sammlung der besten Reisebeschreibungen \n",
"6 Z167356806 Beschreibung der äussern und innern Merkwürdig... \n",
"7 Z69872607 Neues Elementarwerk für die niedern Klassen la... \n",
"8 Z6987270X Neues Elementarwerk für die niedern Klassen la... \n",
"\n",
" Autor Erscheinungsjahr \n",
"0 1784 \n",
"1 1784 \n",
"2 Forster, Georg1754-1794(DE-588)118534416edtO:H... 1792 \n",
"3 Traßler, Joseph Georg1759-1816(DE-588)12926235... 1784 \n",
"4 1784 \n",
"5 1784 \n",
"6 Rumpf, Friedrichaut 1794 \n",
"7 Fabri, Johann Ernst1755-1825(DE-588)11536028Xa... 1790 \n",
"8 Fabri, Johann Ernst1755-1825(DE-588)11536028Xa... 1790 "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 1
}