– another proof of the power of YQL and YUI

This weekend I was bored and thought I'd use one of the awesome data sets the Guardian released lately for free use: a list of all the medals won at the Winter Olympics from 1924 onwards. Using this, with YQL and YUI, I built, a research interface that allows you to check the history of Winter Olympics medals by country, year, sport, and games:

winter olympics medals

the medals grid

Detail page for France

The data was released by the Guardian as an excel sheet on Google Docs, so the first step for me was to download the information and save it as a CSV file. Originally I started using PHP to convert the CSV and parse it, but then I realized it made more sense to use YQL to allow myself to access and filter the data in the CSV in a more flexible way.

However, if you use YQL to parse the CSV you get not very useful identifiers back. If you run the following request in YQL:

select * from csv where url=""

What you will get back is row/col data:

<?xml version="1.0" encoding="UTF-8"?>
<query ...>
<col6>Event gender</col6>
<col3>Figure skating</col3>

As this was not quite useful to me for parameters, I put together an open table to convert these to more meaningful XML tags. Using this one like so:

use "" as medals;
select * from medals;
<?xml version="1.0" encoding="UTF-8"?>
<gender>Event gender</gender>
<discipline>Figure skating</discipline>

This allows me to run lookups in YQL:

Cool, eh? Now, using this with some YUI3 magic, a lick of CSS, and the ever so handy YUI2 datatable, putting together was quite easy.

I will talk about the whole process and release the source code next week at Ignite London and in more depth at Mix 10 in Las Vegas in a few weeks. For now, have fun using the "API."

Chris Heilmann
Yahoo Developer Network