Analyzing the FIFA2010 worldcup with Guardian Data and YQL
Wednesday, July 14th, 2010 at 10:20 amBreaking news: The Guardian once again involved in committing a data awesome! As before, the UK newspaper graced developers with a really cool piece of information published on the web: all the World Cup 2010 statistics as an Excel Sheet.
Now, the easiest way to play with this data is to use YQL, so I simply took a copy of the information and shared it as a CSV document on Google Docs. That way I can use it in YQL:
key=0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc&single=true&gid=1&x=1&
output=csv" and columns="surname,team,position,time,shots,passes,tackles,saves"```
You can [Try this out in the console](http://developer.yahoo.com/yql/console/?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26x%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22) and [see the results here](http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26x%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22).
Using YQL to filter and sort this, you can do some interesting searches on that information. For example:
## What were the German mid field Players?
```markupselect * from csv where url="http://spreadsheets.google.com/pub?
key=0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc&single=true&gid=1&x=1&
output=csv" and columns="surname,team,position,time,shots,passes,tackles,saves"
and team="Germany" and position="Midfielder"```
You can [Try this out in the console](http://developer.yahoo.com/yql/console/?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26x%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22%20and%20team%3D%22Germany%22%20and%20position%3D%22Midfielder%22) and [see the results here](http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26x%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22%20and%20team%3D%22Germany%22%20and%20position%3D%22Midfielder%22&diagnostics=true).
Using sort() and reverse() you can do rankings. For example:
## Who was the goalkeeper with the most saves?
(Neuner of Germany, Kingson of Ghana and Enyeama of Nigeria in case you wonder)
```markupselect * from csv where url="http://spreadsheets.google.com/pub?
key=0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc&single=true&gid=1&x=1&
output=csv" and
columns="surname,team,position,time,shots,passes,tackles,saves"
and position="Goalkeeper" \| sort(field="saves") \| reverse()```
You can [Try this out in the console](http://developer.yahoo.com/yql/console/?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26x%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22%20and%20position%3D%22Goalkeeper%22%20%7C%20sort%28field%3D%22saves%22%29%20%7C%20reverse%28%29) and [see the results here](http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26x%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22%20and%20position%3D%22Goalkeeper%22%20%7C%20sort(field%3D%22saves%22)%20%7C%20reverse()&diagnostics=true).
## Which was the player that spent most time on the pitch?
```markupselect * from csv where url="http://spreadsheets.google.com/pub?
key=0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc&single=true&gid=1&
output=csv" and
columns="surname,team,position,time,shots,passes,tackles,saves"
\| sort(field="time") \| reverse()```
You can [Try this out in the console](http://developer.yahoo.com/yql/console/?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22%20%7C%20sort%28field%3D%22time%22%29%20%7C%20reverse%28%29) and [see the results here](http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22%20%7C%20sort(field%3D%22time%22)%20%7C%20reverse()&diagnostics=true).
## Who were the players who were the least on the pitch in the German and Brazilian teams?
```markupselect * from csv where url="http://spreadsheets.google.com/pub?
key=0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc&single=true&gid=1&x=1&
output=csv" and columns="surname,team,position,time,shots,passes,tackles,saves"
and team in ("Germany","Brazil") \| sort(field="time")```
You can [Try this out in the console](http://developer.yahoo.com/yql/console/?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26x%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22%20and%20team%20in%20%28%22Germany%22%2C%22Brazil%22%29%20%7C%20sort%28field%3D%22time%22%29) and [see the results here](http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Fspreadsheets.google.com%2Fpub%3Fkey%3D0AhphLklK1Ve4dEdrWC1YcjVKN0ZRbTlHQUhaWXBKdGc%26single%3Dtrue%26gid%3D1%26x%3D1%26output%3Dcsv%22%20and%20columns%3D%22surname%2Cteam%2Cposition%2Ctime%2Cshots%2Cpasses%2Ctackles%2Csaves%22%20and%20team%20in%20(%22Germany%22%2C%22Brazil%22)%20%7C%20sort(field%3D%22time%22)&diagnostics=true).
Using the CSV output and YQL you can do all kind of cool things with that data – as YQL also releases it as JSON it makes it easy to create interactive interfaces and visualizations, too – why don’t you have a go?
Tags: [analysis](/tag/analysis/), [data](/tag/data/), [fifa](/tag/fifa/), [fifa2010](/tag/fifa2010/), [guardian](/tag/guardian/), [yql](/tag/yql/)