Skip to content

Instantly share code, notes, and snippets.

View ruthtillman's full-sized avatar

Ruth ruthtillman

View GitHub Profile
@ruthtillman
ruthtillman / cleanerApp.py
Created October 28, 2016 17:57
Cleaner App dictionary for transforming UTF-8 Weirdness to Unicode formatted as \u0000.
def cleanerApp(content):
rdict = {'\xc3\x80':'\u00c0', '\xc3\x81':'\u00c1', '\xc3\x82':'\u00c2', '\xc3\x83':'\u00c3', '\xc3\x84':'\u00c4', '\xc3\x85':'\u00c5', '\xc3\x86':'\u00c6', '\xc3\x87':'\u00c7', '\xc3\x88':'\u00c8', '\xc3\x89':'\u00c9', '\xc3\x8a':'\u00ca', '\xc3\x8b':'\u00cb', '\xc3\x8c':'\u00cc', '\xc3\x8d':'\u00cd', '\xc3\x8e':'\u00ce', '\xc3\x8f':'\u00cf', '\xc3\x90':'\u00d0', '\xc3\x91':'\u00d1', '\xc3\x92':'\u00d2', '\xc3\x93':'\u00d3', '\xc3\x94':'\u00d4', '\xc3\x95':'\u00d5', '\xc3\x96':'\u00d6', '\xc3\x97':'\u00d7', '\xc3\x98':'\u00d8', '\xc3\x99':'\u00d9', '\xc3\x9a':'\u00da', '\xc3\x9b':'\u00db', '\xc3\x9c':'\u00dc', '\xc3\x9d':'\u00dd', '\xc3\x9e':'\u00de', '\xc3\x9f':'\u00df', '\xc3\xa0':'\u00e0', '\xc3\xa1':'\u00e1', '\xc3\xa2':'\u00e2', '\xc3\xa3':'\u00e3', '\xc3\xa4':'\u00e4', '\xc3\xa5':'\u00e5', '\xc3\xa6':'\u00e6', '\xc3\xa7':'\u00e7', '\xc3\xa8':'\u00e8', '\xc3\xa9':'\u00e9', '\xc3\xaa':'\u00ea', '\xc3\xab':'\u00eb', '\xc3\xac':'\u00ec', '\xc3\xad':'\u00ed', '\xc3\xae':'\u00ee',
@ruthtillman
ruthtillman / dc-fug-meeting-2015-10-07.md
Last active October 7, 2015 18:46
Notes from the DC Fedora Users Group, 2015-10-07

Fedora 4 DC User Group Meeting 2015-10-07

Andrew Woods presentation.

Image

Rest Framework ---

} Access & Preservation Services

@ruthtillman
ruthtillman / excel-index-match-lookup.md
Created September 30, 2015 15:20
Description of how I used INDEX & MATCH in Excel to look up data from the org table for another table.

Notes on Using Excel's MATCH and INDEX Functions

To help me get through this faster in future.

Data:

Sheet Authors has various data about a person, including their Org code in Column C.

Sheet Orgs has Column A with the Org code (matching Column C's codes) and Column B with the Title of the Organization.

@ruthtillman
ruthtillman / intro-to-sql-basic-database.sql
Created September 25, 2015 23:38
A sample database used in my Introduction to SQL for Librarians post. Can be pasted into SQLFiddle.com to create a database for experimentation.
CREATE TABLE books
(`id` INT, `title` varchar(225), `location` varchar(12), `publisher` varchar(100), `publication_date` INT(4) )
;
INSERT INTO books
(`id`, `title`, `location`, `publisher`, `publication_date`)
VALUES
(1, 'Semantic Web for the Working Ontologist: Effective Modeling in RDFS and OWL', 'ebook', 'Morgan Kaufmann Publishers', 2008 ),
(2, 'The Fifth Season', 'new', 'Orbit', 2015 ),
(3, 'Ancillary Justice', 'new', 'Orbit', 2013),
<fbm:modifyDatastream pid="\1" dsID="RELS-EXT" dsControlGroupType="X" dsLabel="colloquia_RELS-EXT_ds" logMessage="BatchModify - modifyDatastream">
<fbm:xmlData>
<rdf:RDF xmlns:rel="info:fedora/fedora-system:def/relations-external#" xmlns:fedora-model="info:fedora/fedora-system:def/model#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="\1">
<rel:isMemberOfCollection xmlns:rel="info:fedora/fedora-system:def/relations-external#" xmlns:rel="info:fedora/fedora-system:def/relations-external#" rdf:resource="info:fedora/collection:3"/>
<rel:isMemberOf xmlns:rel="info:fedora/fedora-system:def/relations-external#" rdf:resource="\2"/>
<fedora-model:hasModel xmlns:fedora-model="info:fedora/fedora-system:def/model#" rdf:resource="info:fedora/cmodel:2"/>
<fedora-model:hasModel xmlns:fedora-model="info:fedora/fedora-system:def/model#" rdf:resource="info:fedora/cmodel:4"/>
<rel:isPartOf xmlns:rel="info:fedora/fedora-system:def/relations-external#" rd

Add new column, based on this column and extract RDF URI

cell.recon.match.id

Merging several columns

(copied from Recipes) You'd need to use the 'cells' variable:

cells["col1"].value + cells["col2"].value

import glob
import os
"""
Loops through all the .xml files in the directory where the script is located and removes the designated string: REMOVETHIS in each filename.
If you want to replace, add your new text as the second argument in replace().
"""
def do_rename_files():
find C:/Path/To/Folders -type f -name "*.pdf" -exec cp {} C:/Path/To/New/Folder \;
<?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"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="text" indent="no" media-type="string"/>
<xsl:strip-space elements="*"/>
<xsl:choose>
<xsl:when test="self::dc:date and text()[matches(.,'^\d{4}\-\d{2}-\d{2}')]">
<xsl:text>^^xsd:date</xsl:text>
</xsl:when>
<xsl:when test="self::dc:date and text()[matches(.,'^\d{4}\-\d{2}')]">
<xsl:text>^^xsd:gYearMonth</xsl:text>
</xsl:when>
<xsl:when test="self::dc:date and text()[matches(.,'^\d{4}')]">
<xsl:text>^^xsd:gYear</xsl:text>
</xsl:when>