Adding records to Islandora: Difference between revisions

No edit summary
Line 1,186: Line 1,186:
"STC 11075"
"STC 11075"
]
]
</pre>
==Script to generate Islandora records from finding aid xml==
<pre style="min-height:38px; margin-left:2em" class="mw-collapsible mw-collapsed" data-expandtext="Expand to see script">
from lxml import etree
from collections import OrderedDict
import codecs
import copy
import io
import json
import re
import sys
import csv
csvF=open("bagotRecord.csv","w",newline='')
fieldnames=["title","id","parent_id","field_resource_type","field_model","field_member_of","field_weight","field_identifier","field_linked_agent","field_creator","field_edtf_date","field_place_published","field_extent","field_rights","field_subject","field_note","field_classification","field_page_opening","field_contents","field_catalog_link","field_finding_aid_link","field_created_published","field_genre","field_iconclass_headings","field_bindings_features","field_bindings_terms","field_transcription","field_digital_image_type","field_microfilm_call_number","field_microfilm_reduction_ratio","field_microfilm_length","field_credit","field_sponsored_by","field_bib_id","field_holdings_id","field_display_hints","file","url_alias"]
writer=csv.DictWriter(csvF,fieldnames=fieldnames)
writer.writeheader()
filename="bagot"
tree = etree.parse(filename+'.xml')
for elem in tree.getiterator():
    if not (
        isinstance(elem, etree._Comment)
        or isinstance(elem, etree._ProcessingInstruction)
    ):
        elem.tag = etree.QName(elem).localname
etree.cleanup_namespaces(tree)
   
nodeList = tree.xpath('//c[@level="item"]')
for node in nodeList:
    callNumber = ""
    accessionNumber = ""
    displayTitle = ""
    titleCreator = ""
    titleAgents = []
    titleLocationCreated = ""
    titleLocationReceived = ""
    locationCreated = {}
    agentCreator = ""
    agentRecipient = ""
    displayDate = ""
    scopecontent = ""
    bioghist = ""
    physfacet = ""
    oddp = ""
    notes = ""
    #date
    dateSearch = node.xpath('did/unitdate')
    for date in dateSearch:
        displayDate = date.text
    #identifier
    identifierSearch = node.xpath('did/unitid')
    for identifier in identifierSearch:
        callNumber = identifier.text
        print(callNumber)
    #title
    titleSearch = node.xpath('did/unittitle')
    for title in titleSearch:
        displayTitle += "".join(title.itertext())
    #notes
    abstractSearch = node.xpath('scopecontent/p')
    for abstract in abstractSearch:
        scopecontent += " ".join(abstract.itertext())
        scopecontent = scopecontent.replace("\n"," ")
    #notes
    noteSearch = node.xpath('bioghist/p')
    for note in noteSearch:
        bioghist += "".join(note.itertext())
        bioghist = bioghist.replace("\n"," ")
    generalNoteSearch = node.xpath('did/physdesc/physfacet')
    for generalNote in generalNoteSearch:
        physfacet += "".join(generalNote.itertext())
    oddNoteSearch = node.xpath('odd/p')
    for oddNote in oddNoteSearch:
        oddp += "".join(oddNote.itertext())
        oddp = oddp.replace(" \n"," ")
    notes='{0} {1} {2} {3}'.format(scopecontent,bioghist,physfacet,oddp)
    notes.replace("  "," ")
    writer.writerow({"title":displayTitle,"id":"","parent_id":"","field_resource_type":"","field_model":"","field_member_of":"","field_weight":"","field_identifier":"","field_linked_agent":"","field_creator":"","field_edtf_date":"","field_place_published":"","field_extent":"","field_rights":"","field_subject":"","field_note":notes,"field_classification":callNumber,"field_page_opening":"","field_contents":"","field_catalog_link":"","field_finding_aid_link":"","field_created_published":displayDate,"field_genre":"","field_iconclass_headings":"","field_bindings_features":"","field_bindings_terms":"","field_transcription":"","field_digital_image_type":"","field_microfilm_call_number":"","field_microfilm_reduction_ratio":"","field_microfilm_length":"","field_credit":"","field_sponsored_by":"","field_bib_id":"","field_holdings_id":"","field_display_hints":"","file":"","url_alias":""})
</pre>
</pre>


Line 1,195: Line 1,286:
}
}
</pre>
</pre>
=Adding images to S3=
=Adding images to S3=
=Importing records to Islandora=
=Importing records to Islandora=

Revision as of 12:58, 11 October 2024

This page is under construction

Generating records

Script to generate Islandora records from given holdings-bib pairs

Dictionary of relator terms

List of Shakespeare quarto call numbers

Script to generate Islandora records from finding aid xml

Sample dictionary of holdings-bib ID pairs

Adding images to S3

Importing records to Islandora

Adding links to the catalog

Script to add links to the catalog using a CSV of link text and record IDs

Sample CSV file with link text and record IDs