Skip to content

Instantly share code, notes, and snippets.

@kschlottmann
Last active February 22, 2020 14:27
Show Gist options
  • Select an option

  • Save kschlottmann/d4bee3b08a731fdfbb1a9367ea5ed86f to your computer and use it in GitHub Desktop.

Select an option

Save kschlottmann/d4bee3b08a731fdfbb1a9367ea5ed86f to your computer and use it in GitHub Desktop.
From a list of ids, pull down marcxml records from CLIO
import requests, csv, json, urllib, time
baseURL = 'https://clio.columbia.edu/catalog/'
endURL = '.marcxml'
with open('inputlist.csv', 'r') as csvfile:
reader = csv.reader(csvfile, delimiter='|', quotechar='"')
for row in reader:
bib = str(row[0])
url = baseURL+bib+endURL
response = requests.get(url)
print(response.content)
time.sleep(15)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/all">
<xsl:for-each select="record/datafield[@tag='852']">
<xsl:value-of select="normalize-space(../controlfield[@tag='001'])"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(subfield[@code='a'])"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(subfield[@code='b'])"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(subfield[@code='h'])"/>
<xsl:text>&#xA;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/all">
<xsl:for-each select="record/datafield[@tag='035'][contains(., 'LC)on')]">
<xsl:value-of select="normalize-space(../controlfield[@tag='001'])"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(../datafield[@tag='040']/subfield[@code='a'])"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(subfield[@code='a'])"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(subfield[@code='a'])"/>
<xsl:text>&#xA;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment