Adding records to Islandora

Revision as of 09:02, 13 September 2024 by EmilyWahl (talk | contribs) (Created page with "<big>'''This page is under construction'''</big> __TOC__ =Generating records= <pre style="min-height:38px; margin-left:2em" class="mw-collapsible mw-collapsed" data-expandtext="Expand to see script"> import requests import xml.etree.ElementTree as ET import csv from relatorDict import relatorDictionary from ShxQuartosList import ShxQuartos from holdingsTestDict import holdingsToBibDictionary headers = {'Authorization': "Token cd639621-cb39-4805-80fa-82734155d9fd"} pa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page is under construction

Generating records

import requests
import xml.etree.ElementTree as ET
import csv
from relatorDict import relatorDictionary
from ShxQuartosList import ShxQuartos
from holdingsTestDict import holdingsToBibDictionary


headers = {'Authorization': "Token cd639621-cb39-4805-80fa-82734155d9fd"}
params = {"of":"xm"}
csvF=open("islandoraRecord.csv","w",newline='', encoding='utf-8')

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_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()

i=1

newRelators=[]

for holdingsID in holdingsToBibDictionary:
	bibID=holdingsToBibDictionary[holdingsID]
	URL = "https://catalog.folger.edu/api/v1/record/"+bibID
	print("bib " + bibID)
	r = requests.request("GET", URL, headers=headers, params=params)
	root = ET.fromstring(r.content)

	sfCode=""
	sfValue=""

	callNums={}
	copyNotes={}
	holdingsIDs={}
	collections=[]
	notes=[]
	subjects=[]

	associatedNames=[]
	genresForms=[]

	#EDTF date
	edtfDate=""
	for controlfield in root.findall("controlfield[@tag='008']"):
		edtfDate=""
		lang=""
		countryCode=""
		full008=controlfield.text
		print("008: "+full008)
		date1=full008[7:11]
		print("Date 1: "+date1)
		date2=full008[11:15]
		print("Date 2: "+date2)
		dateType=full008[6]
		print("Type: "+dateType)
		lang=full008[35:38]
		countryCode=full008[15:18]

		if dateType=="b" or (date1=="\\\\" and date2=="\\\\"):
			edtfDate="XXXX"
		elif dateType=="c" or dateType=="u":
			edtfDate=date1+"/.."
		elif dateType=="d":
			edtfDate=date1+"/"+date2
		elif dateType=="e":
			edtfDate=date1+"-"+date2[0:2]+"-"+date2[2:4]
		elif dateType=="i" or dateType=="k" or dateType=="m":
			if date1==date2:
				edtfDate=date1
			else:
				edtfDate=date1+"/"+date2
		elif dateType=="n":
			edtfDate="XXXX"
		elif dateType=="p" or dateType=="r" or dateType=="t":
			edtfDate=date1
		elif dateType=="q":
			edtfDate=date1+"/"+date2
		elif dateType=="s":
			edtfDate=date1
		edtfDate=edtfDate.replace("u","X")

	full007=""
	for controlfield in root.findall("controlfield[@tag='007']"):
		full007=controlfield.text

	#creator: 100%%abcdejq  110%%abcde  111%%acdejq
	creator=""
	for datafield in root.findall("datafield[@tag='100']"):
		dict100={}
		#find first indicator
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict100[sfCode]=sfValue
			sfCode=""
			sfValue=""
		creator=""
		if "e" in dict100:
			relatorTerm=dict100["e"]
			relatorTerm=relatorTerm.rstrip("., ")
			if relatorTerm in relatorDictionary:
				relatorCode=relatorDictionary[relatorTerm]
			else:
				relatorCode="relators:TEST"
				newRelators.append(relatorTerm+": https://catalog.folger.edu/record/"+bibID)

			creator=relatorCode+":"
		else:
			creator="relators:cre:"
		creator=creator+"person:" 
		if "a" in dict100:
			creator=creator+" "+(dict100["a"])
		if "b" in dict100:
			creator=creator+" "+(dict100["b"])
		if "c" in dict100:
			creator=creator+" "+(dict100["c"])
		if "d" in dict100:
			creator=creator+" "+(dict100["d"])
		#if "e" in dict100:
			#creator=creator+" "+(dict100["e"])
		if "j" in dict100:
			creator=creator+" "+(dict100["j"])
		if "q" in dict100:
			creator=creator+" "+(dict100["q"])
		creator=creator.rstrip("., ")
		creator=creator.replace("  "," ")

	for datafield in root.findall("datafield[@tag='110']"):
		dict110={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict110[sfCode]=sfValue
			sfCode=""
			sfValue=""
		creator=""
		if "e" in dict110:
			relatorTerm=dict110["e"]
			relatorTerm=relatorTerm.rstrip("., ")
			if relatorTerm in relatorDictionary:
				relatorCode=relatorDictionary[relatorTerm]
			else:
				relatorCode="relators:TEST"
				newRelators.append(relatorTerm+": https://catalog.folger.edu/record/"+bibID)
			creator=relatorCode+":"
		else:
			creator="relators:cre:"
		creator=creator+"corporate_body:" 
		if "a" in dict110:
			creator=creator+" "+(dict110["a"])
		if "b" in dict110:
			creator=creator+" "+(dict110["b"])
		if "c" in dict110:
			creator=creator+" "+(dict110["c"])
		if "d" in dict110:
			creator=creator+" "+(dict110["d"])
		creator=creator.rstrip("., ")
		creator=creator.replace("  "," ")


	for datafield in root.findall("datafield[@tag='111']"):
		dict111={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict111[sfCode]=sfValue
			sfCode=""
			sfValue=""
		creator=""
		if "e" in dict110:
			relatorTerm=dict110["e"]
			relatorTerm=relatorTerm.rstrip("., ")
			if relatorTerm in relatorDictionary:
				relatorCode=relatorDictionary[relatorTerm]
			else:
				relatorCode="relators:TEST"
				newRelators.append(relatorTerm+": https://catalog.folger.edu/record/"+bibID)
			creator=relatorCode+":"
		else:
			creator="relators:cre:"
		creator=creator+"corporate_body:" 
		if "a" in dict111:
			creator=creator+" "+(dict111["a"])
		if "c" in dict111:
			creator=creator+" "+(dict111["c"])
		if "d" in dict111:
			creator=creator+" "+(dict111["d"])
		if "j" in dict111:
			creator=creator+" "+(dict111["j"])
		if "q" in dict111:
			creator=creator+" "+(dict111["q"])
		creator=creator.rstrip("., ")
		creator=creator.replace("  "," ")

	#title: 245%%abcfghknps 
	title=""
	for datafield in root.findall("datafield[@tag='245']"):
		dict245={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict245[sfCode]=sfValue
			sfCode=""
			sfValue=""
		title=""
		title=dict245["a"]
		if "b" in dict245:
			title=title+" "+(dict245["b"])
		if "c" in dict245:
			title=title+" "+(dict245["c"])
		if "f" in dict245:
			title=title+", "+(dict245["f"])
		if "g" in dict245:
			title=title+" "+(dict245["g"])
		if "h" in dict245:
			title=title+" "+(dict245["h"])
		if "k" in dict245:
			title=title+" "+(dict245["k"])
		if "n" in dict245:
			title=title+" "+(dict245["n"])
		if "p" in dict245:
			title=title+" "+(dict245["p"])
		if "s" in dict245:
			title=title+" "+(dict245["s"])
		title=title.rstrip(".,/ ")
		title=title.replace("  "," ")

	#created/published: 260%%,264%_
	createdPublished=""
	for datafield in root.findall("datafield[@tag='260']"):
		dict260={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict260[sfCode]=sfValue
			sfCode=""
			sfValue=""
		
		if "a" in dict260:
			createdPublished=createdPublished+(dict260["a"])
		if "b" in dict260:
			createdPublished=createdPublished+" "+(dict260["b"])
		if "c" in dict260:
			createdPublished=createdPublished+" "+(dict260["c"])
	for datafield in root.findall("datafield[@tag='264']"):
		dict264={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict264[sfCode]=sfValue
			sfCode=""
			sfValue=""
		if createdPublished=="":
			if "a" in dict264:
				createdPublished=createdPublished+(dict264["a"])
			if "b" in dict264:
				createdPublished=createdPublished+" "+(dict264["b"])
			if "c" in dict264:
				createdPublished=createdPublished+" "+(dict264["c"])
	createdPublished=createdPublished.rstrip("., ")

	#notes: MARC: 510$ac (when first indicator is 3 or 4) 
	for datafield in root.findall("datafield[@tag='510']"):
		dict510={}
		if datafield.attrib["ind1"]=="3" or datafield.attrib["ind1"]=="4":
			for subfield in datafield.findall("subfield"):
				sfCode=subfield.attrib['code']#
				sfValue=subfield.text
				dict510[sfCode]=sfValue
				sfCode=""
				sfValue=""
			note="Reference citation note: "
			if "a" in dict510:
				note=note+(dict510["a"])
			if "c" in dict510:
				note=note+" "+(dict510["c"])
			notes.append(note)

	#subjects 600%%abcdt 
	#         610%%abcdt
	#         611%%acdt
	#         650%%a
	#		  651%%a
	for datafield in root.findall("datafield[@tag='600']"):
		dict600={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict600[sfCode]=sfValue
			sfCode=""
			sfValue=""
		subject=""
		if "a" in dict600:
			subject=subject+(dict600["a"])
		if "b" in dict600:
			subject=subject+" "+(dict600["b"])
		if "c" in dict600:
			subject=subject+" "+(dict600["c"])
		if "d" in dict600:
			subject=subject+" "+(dict600["d"])
		if "t" in dict600:
			subject=subject+" "+(dict600["t"])
		subject=subject.replace("  "," ")
		subject=subject.rstrip("., ")
		subjects.append(subject)
	for datafield in root.findall("datafield[@tag='610']"):
		dict610={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict610[sfCode]=sfValue
			sfCode=""
			sfValue=""
		subject=""
		if "a" in dict610:
			subject=subject+(dict610["a"])
		if "b" in dict610:
			subject=subject+" "+(dict610["b"])
		if "c" in dict610:
			subject=subject+" "+(dict610["c"])
		if "d" in dict610:
			subject=subject+" "+(dict610["d"])
		if "t" in dict610:
			subject=subject+" "+(dict610["t"])
		subject=subject.replace("  "," ")
		subject=subject.rstrip("., ")
		subjects.append(subject)
	for datafield in root.findall("datafield[@tag='611']"):
		dict611={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict611[sfCode]=sfValue
			sfCode=""
			sfValue=""
		subject=""
		if "a" in dict611:
			subject=subject+(dict611["a"])
		if "c" in dict611:
			subject=subject+" "+(dict611["c"])
		if "d" in dict611:
			subject=subject+" "+(dict611["d"])
		if "t" in dict611:
			subject=subject+" "+(dict611["t"])
		subject=subject.replace("  "," ")
		subject=subject.rstrip("., ")
		subjects.append(subject)
	for datafield in root.findall("datafield[@tag='650']"):
		dict650={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict650[sfCode]=sfValue
			sfCode=""
			sfValue=""
		subject=""
		if "a" in dict650:
			subject=subject+(dict650["a"])
		subject=subject.replace("  "," ")
		subject=subject.rstrip("., ")
		subjects.append(subject)
	for datafield in root.findall("datafield[@tag='651']"):
		dict651={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict651[sfCode]=sfValue
			sfCode=""
			sfValue=""
		subject=""
		if "a" in dict651:
			subject=subject+(dict651["a"])
		subject=subject.replace("  "," ")
		subject=subject.rstrip("., ")
		subjects.append(subject)

	#genre/form: 655%%3;a;x;y;z
	for datafield in root.findall("datafield[@tag='655']"):
		dict655={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict655[sfCode]=sfValue
			sfCode=""
			sfValue=""
		genreForm=""
		if "a" in dict655:
			genreForm=genreForm+(dict655["a"])
		if "x" in dict655:
			genreForm=genreForm+(dict655["x"])
		if "y" in dict655:
			genreForm=genreForm+" "+(dict655["y"])
		if "z" in dict655:
			genreForm=genreForm+" "+(dict655["z"])
		genreForm=genreForm.rstrip("., ")
		genresForms.append(genreForm)

	#associated name: 700%%abcdejq  710%%abcde  711%%acdejq  800%%abcdejq  810%%abcde  811%%acdejq
	for datafield in root.findall("datafield[@tag='700']"):
		dict700={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict700[sfCode]=sfValue
			sfCode=""
			sfValue=""
		associatedName=""
		if "e" in dict700:
			relatorTerm=dict700["e"]
			relatorTerm=relatorTerm.rstrip("., ")
			if relatorTerm in relatorDictionary:
				relatorCode=relatorDictionary[relatorTerm]
			else:
				relatorCode="relators:TEST"
				newRelators.append(relatorTerm+": https://catalog.folger.edu/record/"+bibID)
			associatedName=relatorCode+":"
		else:
			associatedName="relators:asn:"
		associatedName=associatedName+"person:" ##CHECK INDICATOR FOR PERSON V FAMILY
		if "a" in dict700:
			associatedName=associatedName+" "+(dict700["a"])
		if "b" in dict700:
			associatedName=associatedName+" "+(dict700["b"])
		if "c" in dict700:
			associatedName=associatedName+" "+(dict700["c"])
		if "d" in dict700:
			associatedName=associatedName+" "+(dict700["d"])
		if "j" in dict700:
			associatedName=associatedName+" "+(dict700["j"])
		if "q" in dict700:
			associatedName=associatedName+" "+(dict700["q"])
		associatedName=associatedName.rstrip("., ")
		associatedName=associatedName.replace("  "," ")
		associatedNames.append(associatedName)

	for datafield in root.findall("datafield[@tag='710']"):
		dict710={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict710[sfCode]=sfValue
			sfCode=""
			sfValue=""
		associatedName=""
		if "e" in dict710:
			relatorTerm=dict710["e"]
			relatorTerm=relatorTerm.rstrip("., ")
			if relatorTerm in relatorDictionary:
				relatorCode=relatorDictionary[relatorTerm]
			else:
				relatorCode="relators:TEST"
				newRelators.append(relatorTerm+": https://catalog.folger.edu/record/"+bibID)
			associatedName=relatorCode+":"
		else:
			associatedName="relators:asn:"
		associatedName=associatedName+"corporate_body:" ##CHECK INDICATOR FOR PERSON V FAMILY
		if "a" in dict710:
			associatedName=associatedName+" "+(dict710["a"])
		if "b" in dict710:
			associatedName=associatedName+" "+(dict710["b"])
		if "c" in dict710:
			associatedName=associatedName+" "+(dict710["c"])
		if "d" in dict710:
			associatedName=associatedName+" "+(dict710["d"])
		associatedName=associatedName.rstrip("., ")
		associatedName=associatedName.replace("  "," ")
		associatedNames.append(associatedName)

	for datafield in root.findall("datafield[@tag='711']"):
		dict711={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict711[sfCode]=sfValue
			sfCode=""
			sfValue=""
		associatedName=""
		if "e" in dict711:
			relatorTerm=dict711["e"]
			relatorTerm=relatorTerm.rstrip("., ")
			if relatorTerm in relatorDictionary:
				relatorCode=relatorDictionary[relatorTerm]
			else:
				relatorCode="relators:TEST"
				newRelators.append(relatorTerm+": https://catalog.folger.edu/record/"+bibID)
			associatedName=relatorCode+":"
		else:
			associatedName="relators:asn:"
		associatedName=associatedName+"corporate_body:" 
		if "a" in dict711:
			associatedName=associatedName+" "+(dict711["a"])
		if "c" in dict711:
			associatedName=associatedName+" "+(dict711["c"])
		if "d" in dict711:
			associatedName=associatedName+" "+(dict711["d"])
		if "j" in dict711:
			associatedName=associatedName+" "+(dict711["j"])
		if "q" in dict711:
			associatedName=associatedName+" "+(dict711["q"])
		associatedName=associatedName.rstrip("., ")
		associatedName=associatedName.replace("  "," ")
		associatedNames.append(associatedName)

	#place created: 752 abcd
	hierarchicalPlaceName=""
	for datafield in root.findall("datafield[@tag='752']"):
		dict752={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']
			sfValue=subfield.text
			dict752[sfCode]=sfValue
			sfCode=""
			sfValue=""
		hierarchicalPlaceName=""
		if "a" in dict752:
			hierarchicalPlaceName=(dict752["a"])
		if "b" in dict752:
			hierarchicalPlaceName=hierarchicalPlaceName+"|"+(dict752["b"])
		if "c" in dict752:
			hierarchicalPlaceName=hierarchicalPlaceName+"|"+(dict752["c"])
		if "d" in dict752:
			hierarchicalPlaceName=hierarchicalPlaceName+"|"+(dict752["d"])
		hierarchicalPlaceName=hierarchicalPlaceName.rstrip("., ")		

	for datafield in root.findall("datafield[@tag='800']"):
		dict800={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict800[sfCode]=sfValue
			sfCode=""
			sfValue=""
		associatedName=""
		if "e" in dict800:
			relatorTerm=dict800["e"]
			relatorTerm=relatorTerm.rstrip("., ")
			if relatorTerm in relatorDictionary:
				relatorCode=relatorDictionary[relatorTerm]
			else:
				relatorCode="relators:TEST"
				newRelators.append(relatorTerm+": https://catalog.folger.edu/record/"+bibID)
			associatedName=relatorCode+":"
		else:
			associatedName="relators:asn:"
		associatedName=associatedName+"person:" ##CHECK INDICATOR 1 FOR PERSON V FAMILY
		if "a" in dict800:
			associatedName=associatedName+" "+(dict800["a"])
		if "b" in dict800:
			associatedName=associatedName+" "+(dict800["b"])
		if "c" in dict800:
			associatedName=associatedName+" "+(dict800["c"])
		if "d" in dict800:
			associatedName=associatedName+" "+(dict800["d"])
		if "e" in dict800:
			associatedName=associatedName+" "+(dict800["e"])
		if "j" in dict800:
			associatedName=associatedName+" "+(dict800["j"])
		if "q" in dict800:
			associatedName=associatedName+" "+(dict800["q"])
		associatedName=associatedName.rstrip("., ")
		associatedName=associatedName.replace("  "," ")
		associatedNames.append(associatedName)

	for datafield in root.findall("datafield[@tag='810']"):
		dict810={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict810[sfCode]=sfValue
			sfCode=""
			sfValue=""
		associatedName=""
		if "e" in dict810:
			relatorTerm=dict810["e"]
			relatorTerm=relatorTerm.rstrip("., ")
			if relatorTerm in relatorDictionary:
				relatorCode=relatorDictionary[relatorTerm]
			else:
				relatorCode="relators:TEST"
				newRelators.append(relatorTerm+": https://catalog.folger.edu/record/"+bibID)
			associatedName=relatorCode+":"
		else:
			associatedName="relators:asn:"
		associatedName=associatedName+"corporate_body:" ##CAN WE DO MEETING?
		if "a" in dict810:
			associatedName=associatedName+" "+(dict810["a"])
		if "b" in dict810:
			associatedName=associatedName+" "+(dict810["b"])
		if "c" in dict810:
			associatedName=associatedName+" "+(dict810["c"])
		if "d" in dict810:
			associatedName=associatedName+" "+(dict810["d"])
		if "e" in dict810:
			associatedName=associatedName+" "+(dict810["e"])
		associatedName=associatedName.rstrip("., ")
		associatedName=associatedName.replace("  "," ")
		associatedNames.append(associatedName)

	for datafield in root.findall("datafield[@tag='811']"):
		dict811={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict811[sfCode]=sfValue
			sfCode=""
			sfValue=""
		associatedName=""
		if "e" in dict811:
			relatorTerm=dict811["e"]
			relatorTerm=relatorTerm.rstrip("., ")
			if relatorTerm in relatorDictionary:
				relatorCode=relatorDictionary[relatorTerm]
			else:
				relatorCode="relators:TEST"
				newRelators.append(relatorTerm+": https://catalog.folger.edu/record/"+bibID)
			associatedName=relatorCode+":"
		else:
			associatedName="relators:asn:"
		associatedName=associatedName+"corporate_body:" 
		if "a" in dict811:
			associatedName=associatedName+" "+(dict811["a"])
		if "c" in dict811:
			associatedName=associatedName+" "+(dict811["c"])
		if "d" in dict811:
			associatedName=associatedName+" "+(dict811["d"])
		if "e" in dict811:
			associatedName=associatedName+" "+(dict811["e"])
		if "j" in dict811:
			associatedName=associatedName+" "+(dict811["j"])
		if "q" in dict811:
			associatedName=associatedName+" "+(dict811["q"])
		associatedName=associatedName.rstrip("., ")
		associatedName=associatedName.replace("  "," ")
		associatedNames.append(associatedName)

	#call num, holdings ID, copy notes
	callNum=""
	for datafield in root.findall("datafield[@tag='852']"):
		dict852={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict852[sfCode]=sfValue
			sfCode=""
			sfValue=""
		callNum=""
		Holdings852=""
		if "7" in dict852:
			Holdings852=dict852["7"]
		else:
			Holdings852=holdingsID
		if "k" in dict852:
			callNum=dict852["k"]
		if "h" in dict852:
			callNum=callNum+" "+dict852["h"]
		if "i" in dict852:
			callNum=callNum+" "+(dict852["i"])
		callNum=callNum.replace("  "," ")
		callNum=callNum.rstrip("., ")
		callNum=callNum.lstrip(" ")
		callNums[Holdings852]=callNum
		if "z" in dict852:
			copyNotes[Holdings852]=dict852["z"]

	numericDate=False
	intDate=0000

	#collection list:
	for controlfield in root.findall("controlfield[@tag='000']"):
		fullLeader=controlfield.text
		recordType=fullLeader[6]
		numericDate=False
		intDate=0000
		try:
			intDate=int(date1.replace("u","0"))
			numericDate=True
		except:
			numericDate=False
		if recordType=="a" or recordType=="c" or recordType=="e":
			#collections.append("74")#Books
			if intDate<=1500 and numericDate==True:
				collections.append("75")#Incunabula
			if intDate<=1640 and numericDate==True:
				if lang=="eng" or countryCode[2]=="k" or countryCode[0:2]=="ie":
					collections.append("76")#STC imprints
					if "h" in dict852:
						stcNumPlus=dict852["h"]
					else:
						stcNumPlus="SKIP"
					copyLoc=stcNumPlus.find(" ",4)
					if copyLoc!=-1:
						stcNum=stcNumPlus[0:copyLoc]
					else:
						stcNum=stcNumPlus
					if stcNum in ShxQuartos:
						#collections.append("91")#Shakespeare
						collections.append("92")#Quartos
					elif stcNum == "STC 22273":
						#collections.append("91")#Shakespeare
						collections.append("93")#First folios
					elif stcNum == "STC 22274":
						#collections.append("91")#Shakespeare
						collections.append("94")#Second folios
			elif intDate>1640 and intDate<=1700 and numericDate==True:
				if lang=="eng" or countryCode[2]=="k" or countryCode[2]=="u" or countryCode[0:2]=="ie":
					collections.append("77")#Wing imprints
					wingNumPlus=dict852["h"]
					copyLoc=wingNumPlus.find(" ")
					if copyLoc!=-1:
						wingNum=wingNumPlus[0:copyLoc]
					else:
						wingNum=wingNumPlus
					if wingNum=="S2913" or wingNum=="S2914":
						#collections.append("91")#Shakespeare
						collections.append("95")#Third folios
					elif wingNum=="S2915" or wingNum=="S2916" or wingNum=="S2917":
						#collections.append("91")#Shakespeare
						collections.append("96")#Fourth folios
			if intDate<1831 and numericDate==True:
				collections.append("78")#Pre-1831 imprints
			elif intDate>1830 and numericDate==True:
				collections.append("79")#Post-1830 imprints
		if recordType=="d" or recordType=="f" or recordType=="t":
			#collections.append("80")#Manuscripts
			if intDate<1701 and numericDate==True:
				collections.append("81")#Pre-1701 manuscripts
			elif intDate>1700 and numericDate==True:
				collections.append("82")#Post-1700 manuscripts
		if recordType=="k" or recordType=="r":
			#collections.append("83")#Art & Objects
			if full007!="":
				matDes=full007[1]
			else:
				matDes=""
			if recordType=="k":
				collections.append("88")#All pictures
				if matDes=="f" or matDes=="j" or matDes=="k" or matDes=="p" or matDes=="s":
					collections.append("84")#Prints
				elif matDes=="g" or matDes=="h" or matDes=="v":
					collections.append("85")#Photos
				elif matDes=="d" or matDes=="l":
					collections.append("86")#Drawings
				if (matDes=="d" and full007[3]=="c") or matDes=="e":
					collections.append("87")#Paintings
			if recordType=="r":
				collections.append("90")#Objects

	#extent: 300$c, art notes: 300$a
	extent=""
	for datafield in root.findall("datafield[@tag='300']"):
		dict300={}
		for subfield in datafield.findall("subfield"):
			sfCode=subfield.attrib['code']#
			sfValue=subfield.text
			dict300[sfCode]=sfValue
			sfCode=""
			sfValue=""
		extent=""
		if "324" in collections:#Art & Objects
			if "a" in dict300:
				extent=dict300["a"] + ": "
		if "c" in dict300:
			extentC=dict300["c"]
			extentC.lstrip("(")
			extentC.rstrip(")")
			extent=extent + extentC
			extent=extent.rstrip("., ")

	rights="https://rightsstatements.org/page/NoC-US/1.0/|https://creativecommons.org/publicdomain/zero/1.0/"
	catalogLink="https://catalog.folger.edu/record/"+bibID
	digitalImageType="High resolution image"
	credit="Folger Imaging Department"

	fullNotes=""
	fullSubjects=""
	fullAssociatedNames=""
	fullGenresForms=""
	fullCollections=""

	notes = list(dict.fromkeys(notes))
	for note in notes:
		if fullNotes=="":
			fullNotes=note
		else:
			fullNotes=fullNotes+"|"+note
	if holdingsID in copyNotes:
		copyNote="Copy note: "+copyNotes[holdingsID]
		print(copyNote)
		if fullNotes=="":
			fullNotes=copyNote
		else:
			fullNotes=fullNotes+"|"+copyNote
	else:
		print("no copy notes")
	subjects = list(dict.fromkeys(subjects))
	for subject in subjects:
		if fullSubjects=="":
			fullSubjects=subject
		else:
			fullSubjects=fullSubjects+"|"+subject
	associatedNames = list(dict.fromkeys(associatedNames))
	for associatedName in associatedNames:
		if fullAssociatedNames=="":
			fullAssociatedNames=associatedName
		else:
			fullAssociatedNames=fullAssociatedNames+"|"+associatedName
	genresForms = list(dict.fromkeys(genresForms))
	for genreForm in genresForms:
		if fullGenresForms=="":
			fullGenresForms=genreForm
		else:
			fullGenresForms=fullGenresForms+"|"+genreForm	
	collections = list(dict.fromkeys(collections))
	for collection in collections:
		if fullCollections=="":
			fullCollections=collection
		else:
			fullCollections=fullCollections+"|"+collection

	writer.writerow({"title":title,"id":i,"parent_id":"","field_resource_type":"collection","field_model":"paged content","field_member_of":fullCollections,"field_weight":"","field_identifier":"","field_linked_agent":fullAssociatedNames,"field_creator":creator,"field_edtf_date":edtfDate,"field_place_published":hierarchicalPlaceName,"field_extent":extent,"field_rights":rights,"field_subject":fullSubjects,"field_note":fullNotes,"field_classification":callNums[holdingsID],"field_page_opening":"","field_contents":"","field_catalog_link":catalogLink,"field_finding_aid_link":"","field_created_published":createdPublished,"field_genre":fullGenresForms,"field_iconclass_headings":"","field_bindings_features":"","field_bindings_terms":"","field_digital_image_type":"","field_microfilm_call_number":"","field_microfilm_reduction_ratio":"","field_microfilm_length":"","field_credit":"","field_sponsored_by":"","field_bib_id":bibID,"field_holdings_id":holdingsID,"field_display_hints":"Mirador","file":"","url_alias":"/bib"+bibID+"-"+holdingsID})
	writer.writerow({"title":"","id":i,"parent_id":"1","field_resource_type":"still image","field_model":"page","field_member_of":"","field_weight":"","field_identifier":"","field_linked_agent":"","field_creator":"","field_edtf_date":"","field_place_published":"","field_extent":"","field_rights":rights,"field_subject":"","field_note":"","field_classification":callNums[holdingsID],"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_digital_image_type":digitalImageType,"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":"Mirador","file":"","url_alias":"/img"})

Adding images to S3

Importing records to Islandora