Created
January 27, 2015 18:46
-
-
Save phette23/55da5a7fc3ad18f92f98 to your computer and use it in GitHub Desktop.
UNT JSON to EQUELLA Taxonomy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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