Skip to content

Instantly share code, notes, and snippets.

@ostephens
ostephens / example-marc-xml-parser.php
Last active May 10, 2019 15:56
example-marc-xml-parser.php
<?php
// TODO
//
// Change dc:subject to tags as with OpenLearn
// Add notes at top of each output file
// Add namespaces at top of each output file
// Add Table of Contents?
$books = "";
$serials = "";
electoral_district_item electoral_district_name parliamentary_group_item parliamentary_group_name person_item person_name
Q7130243 Panchagarh-1 Q6164619 Jatiya Samajtantrik Dal Q47440979 Nazmul Haque Prodhan
Q7130244 Panchagarh-2 Q1281480 Bangladesh Awami League Q15837138 Nurul Islam Sujan
Q24692950 Thakurgaon-1 Q1281480 Bangladesh Awami League Q15841687 Ramesh Chandra Sen
Q24692952 Thakurgaon-2 Q1281480 Bangladesh Awami League Alhaj Md. Dabirul Islam
Q24692955 Thakurgaon-3 Q4382630 Workers Party of Bangladesh Q23415067 Md. Yeasin Ali
Q24692971 Dinajpur-1 Q1281480 Bangladesh Awami League Q15043824 Manoranjan Shill Gopal
Q24693201 Dinajpur-2 Q1281480 Bangladesh Awami League Q52157980 Khalid Mahmud Chowdhury
Q24693203 Dinajpur-3 Q1281480 Bangladesh Awami League Q50405663 Iqbalur Rahim
Q24693206 Dinajpur-4 Q1281480 Bangladesh Awami League Q16058009 Abul Hassan Mahmood Ali
person_name person_item electoral_district_name electoral_district_item parliamentary_group_name parliamentary_group_item
T.P.R. Selvame Mannadipet Q6750715 All India N.R. Congress Q1166149
B. Kobiga Thirubuvanai Q7785260 All India N.R. Congress Q1166149
E. Theeppainthan Ossudu Q7107543 Indian National Congress Q10225
S.V. Sugumaran Mangalam Q6748672 All India N.R. Congress Q1166149
A. Namassivayam Q24572352 Villianur Q7931090 Indian National Congress Q10225
Mnr. Balan Ozhukarai Q16919338 Indian National Congress Q10225
N.S.J. Jayabal Kadirkamam Q6345566 All India N.R. Congress Q1166149
N. Rangasamy Q599267 Indira Nagar Q6025049 All India N.R. Congress Q1166149
Ashok Anand Thattanchavady Q7711405 All India N.R. Congress Q1166149
Col1 Col2 Col3
ValueA ValueB ValueC
ValueD ValueE ValueF
@ostephens
ostephens / gist:75f53bcf65821e72dedb
Created June 4, 2015 16:42
Extract URL from 856$u in MARC (Ruby)
!/usr/bin/ruby
require 'rubygems'
require 'marc'
require 'optparse'
require 'CSV'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: 001-856.rb [options]"
[
{
"op": "core/column-addition",
"description": "Create column Material Description at index 1 based on column Description using expression grel:value.replace(/\\n/,\" \").match(/(.*)Typewritten text:(.*)/)[0]",
"engineConfig": {
"facets": [],
"mode": "row-based"
},
"newColumnName": "Material Description",
"columnInsertIndex": 1,
@ostephens
ostephens / Include date of birth in SPARQL results
Created April 20, 2015 18:05
Include date of birth in SPARQL results when selecting by DoB in query on BNB
PREFIX bio: <http://purl.org/vocab/bio/0.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?author ?name ?dob WHERE {
?event a bio:Birth;
bio:date "1945"^^xsd:gYear;
bio:date ?dob.
?author bio:event ?event;
foaf:name ?name.
@ostephens
ostephens / gist:d2bd979968e28f62dfca
Created November 20, 2014 16:49
BM Satires with one line per ID
PREFIX crm: <http://erlangen-crm.org/current/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX thes: <http://collection.britishmuseum.org/id/thesauri/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bmo: <http://collection.britishmuseum.org/id/ontology/>
PREFIX thesIdentifier: <http://collection.britishmuseum.org/id/>
SELECT DISTINCT ?id (GROUP_CONCAT(?title; SEPARATOR = "|") as ?titles) (GROUP_CONCAT(?name; SEPARATOR = "|") as ?names) (GROUP_CONCAT(?desc; SEPARATOR = "|") as ?descs) (GROUP_CONCAT(?date; SEPARATOR = "|") as ?dates)
{
?object crm:P70i_is_documented_in <http://collection.britishmuseum.org/id/bibliography/294> .
OPTIONAL {
@ostephens
ostephens / gist:43e7d7a967a147ed4e8f
Last active December 10, 2015 18:28
SPARQL for British Museum Satires with titles and dates
PREFIX crm: <http://erlangen-crm.org/current/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX thes: <http://collection.britishmuseum.org/id/thesauri/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bmo: <http://collection.britishmuseum.org/id/ontology/>
PREFIX thesIdentifier: <http://collection.britishmuseum.org/id/>
SELECT DISTINCT ?id ?title ?name ?desc ?date
{
?object crm:P70i_is_documented_in <http://collection.britishmuseum.org/id/bibliography/294> .
OPTIONAL {
@ostephens
ostephens / gist:c6ef3999e1b6da9634ce
Created May 14, 2014 09:27
SPARQL for books by Jane Austen from RLUK LOD
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?s ?o
WHERE {
?s <http://rdaregistry.info/Elements/u/P60447> ?b .