Published
Edited
Jul 15, 2021
Importers
1 star
Insert cell
md `# Bibliography Wrangling`
Insert cell
res = d3.json("https://raw.githubusercontent.com/StevenMDrucker/ResearchContent/master/researchData.json")
Insert cell
t = res.map((a)=>{return {...a, subject: a.tags.subject, venue: a.tags.publication[0], authors: a.tags.collaborators, description:a.abstract ,layout:"publication", year:parseInt(a.tags.year[0])}})
Insert cell
t[10]
Insert cell
Insert cell
DOM.download(serializestring(theresult), null, "Download old json as yml")
Insert cell
Insert cell
Insert cell
foo = attachment.text()
Insert cell
bibentries = bib.parse(foo)
Insert cell
entries = bibentries.filter((a)=>{if (a.itemtype == "entry") return(a)})
Insert cell
finalentries = entries.map( (entry) => {let obj = Object.assign({...entry}, ...entry.fields.map((x) => ({[x.name]: x.value}))); delete(obj.fields); return(obj)})
Insert cell
finalentriessort = entries.sort( (a,b)=> {return (a.year - b.year)})

Insert cell
//reordered = finalentriessort.map( (a) => {let c = a.title; let obj = Object.assign({caption: c, ...a}); return obj})
Insert cell
druckerentries = finalentries.filter( (a) => {let b = a.author; if (b) return b.includes("Drucker")})
Insert cell
des = druckerentries
Insert cell
// yml.dump(druckerentries)
Insert cell
ymlfile = FileAttachment("newpubs@5.yml");
Insert cell
baz = ymlfile.text()
Insert cell
druckerpubsfromhomepage = yml.load(baz)
Insert cell
DOM.download(serializestring( yml.dump(druckerentries)), "acmyml.yml", "Download new bibtex as yml")
Insert cell
druckerpubsfromhomepage
Insert cell
druckerpubsfromhomepage[9]
Insert cell
druckerentries[0].title
Insert cell
druckerentries[4]
Insert cell
function findcaptioninlist(acaption, alist) {
return alist.filter( (b) => {return (b.caption.toLowerCase () == acaption.toLowerCase())})}
Insert cell
findcaptioninlist(druckerentries[4].title, druckerpubsfromhomepage)
Insert cell
druckerentries.map( (de)=> {return( Object.assign( de, findcaptioninlist(de.title, druckerpubsfromhomepage)))})
Insert cell
dtable = aq.from(des)
Insert cell
dtable.view()
Insert cell
DOM.download(serializestring(dtable.toCSV()), "druckerbibtext.csv", "Download new bibtex as csv")
Insert cell
homepagetable = aq.from(t)
Insert cell
homepagetable.view()
Insert cell
newtable = homepagetable.orderby('year').derive( {UKEY: d=>100000+op.row_number()*100})
Insert cell
newtable.view()
Insert cell
csvbib = FileAttachment("acmcvinfocsv.csv").text()
Insert cell
bibtextable = aq.fromCSV(csvbib)
Insert cell
bibtextable.view()
Insert cell
newtable.view()
Insert cell
joinedtable = newtable.join_full(bibtextable, 'UKEY')
Insert cell
joinedtable.view()
Insert cell
DOM.download(serializestring(joinedtable.toJSON()), "joinedtable.json", "Download Joined Table as json")
Insert cell
DOM.download(serializestring(joinedtable.toCSV()), "joinedtable.csv", "Download Joined Table as csv")
Insert cell
DOM.download(serializestring(homepagetable.toCSV()), "druckerhomepage.csv", "Download homepage as csv")
Insert cell
homepagetable.column('bibEntry').data[0]
Insert cell
bazinga = druckerentries[24]
Insert cell
{
var flatten = function (o) {
var tempA = {};
for (let i in o) {
if ((typeof o[i]) == 'object') {
var tempB = flatten(o[i]);
for (let j in tempB) { tempA[i + '.' + j] = tempB[j]; }
} else { tempA[i] = o[i]; }
}
return tempA;
};
return flatten(druckerentries)
}
Insert cell
keflui = findcaptioninlist(druckerentries[24].title, druckerpubsfromhomepage)[0]
Insert cell
Object.assign(keflui, bazinga)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {aq, op} from '@uwdata/arquero'
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more