Partially Attended

an irregularly updated blog by Ian Mulvany

blog posts about programming

Hunting for structure in nested JSON with python just got a whole lot easier

A very common python task that I find myself stumbling over repeatedly is trying to get the syntax right to address or retrieve a specific value to a key in a dented JSON document, in particular if that key is some way down the tree. I’ve just found the library https://github.com/mahmoud/glom which is written up really nicely here: https://sedimental.org/glom_restructured_data.html Before looking at this modele in detail I had thought that I could pass a reference to a key to glom without specifying its location fully in the structure of the input file, but after looking at this for a moment it became clear that this is not what it does, but rather is good at helping to remap nested data structures into new structures, and accessing the data you want via path like queries. ... (more)

Reverse DOI lookups with Crossref

Today I had a need to think about how to do a reverse lookup of a formatted citation to find a DOI. @CrossrefOrg helped out and pointed me to the reverse api endpoint. It workes like this: http://api.crossref.org/reverse Created a json payload file “citation.json” formatted as follows: [ " Curtis, J. R., Wenrich, M. D., Carline, J. D., Shannon, S. E., Ambrozy, D. M., & Ramsey, P. G. (2001). Understanding physicians’ skills at providing end-of-life care: Perspectives of patients, families, and health care workers. ... (more)

If programming is magic, then the old languages are strong

The similarity between magic and programming is never more apparent thanwhen you sit down and watch someone who is truly good on the command line.By virtue of having secret knowledge they can quickly accomplish theapparently impossible. If you start out in the unix world you begin bylearning some simple incantations such as 'cd', 'ls' and 'top' and 'kill'.If you persevere with the art eventually you may master the hidden runesthat bring 'sed' and 'awk' to life. ... (more)