python

Parsing JSON with Python

My personal quick reference

It seems like every few months I have a project where I need to parse some JSON and pull out certain parts. Maybe the JSON came in JSON files, or maybe I retrieved it from an API. The duration between each of these occasions is long enough that I’ve had to relearn some basics each time, so a year or two ago I made a sample JSON file that demonstrates a few data structures and features, and then I wrote a Python demo script that parses them. Now I look at that script to review the basics…

Pipelining SPARQL queries in memory with the rdflib Python library

Using retrieved data to make more queries.

Last month in Dividing and conquering SPARQL endpoint retrieval I described how you can avoid timeouts for certain kinds of SPARQL endpoint queries by first querying for the resources that you want to know about and then querying for more data about those resources a subset at a time using the VALUES keyword. (The example query retrieved data, including the latitude and longitude, about points within a specified city.) I built my demo with some shell scripts, some Perl scripts, and a bit of spit…

Note: I wrote this blog entry to accompany the IBM Data Magazine piece mentioned in the first paragraph, so for people following the link from there this goes into a little more detail on what RDF, triples, and SPARQL are than I normally would on this blog. I hope that readers already familiar with these standards will find the parts about doing the inferencing on a Hadoop cluster interesting.

Expand those shortened URLs before archiving twitter messages

What if a shortening service goes down?

People love to talk about the implications of twitter.com going down, but what if a URL-shortening service goes down? When I had trouble getting to is.gd recently, I realized that when they’re down tweets referencing is.gd URLs are worthless—and that it wouldn’t be too difficult to do something about it before this happens. (I have wondered, though: why doesn’t twitter grab some short domain name and offer their own shortening service?) After all, if you’re saving any…

My own little Twitter client

No AJAX, Flash, or AIR; just HTML, but arranged the way I want it.

I’ve tried various Twitter clients, but usually just went back to the twitter.com web-based interface that people hate so much. My main complaint with it—and I saw no other clients that did any better—was that it showed tweets in reverse chronological order. Conversations and the multi-tweet mini-essays that some people write are difficult to read that way, so I decided to write my own little client.