Skip to content

Instantly share code, notes, and snippets.

@phette23
Created January 27, 2015 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phette23/55da5a7fc3ad18f92f98 to your computer and use it in GitHub Desktop.
Save phette23/55da5a7fc3ad18f92f98 to your computer and use it in GitHub Desktop.
UNT JSON to EQUELLA Taxonomy
// take http://digital2.library.unt.edu/vocabularies/agent-qualifiers/json/
// and insert into an EQUELLA taxonomy, preserving URL & definition info
// EQUELLA taxo format is CSV-like:
// term1/term/term2,key,value,key2,value2…
// can then upload with their included Python scripts or write your own
var fs = require('fs')
var data = JSON.parse(fs.readFileSync('agent-qualifiers.json'))
var terms = data.terms
var getDescription = function(term) {
var props = term.properties,
len = props.length,
i;
for (i = 0; i < len; i++) {
if (props[i].property_name === 'definition') {
return props[i].label
}
}
return 'No description available';
}
var quote = function(str) {
return '"' + str + '"';
}
terms.forEach(function(term) {
console.log([
quote(term.label), // taxonomy term
quote('url'), // key
quote(term.url), // value
quote('description'),
quote(getDescription(term))
].join(','))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment