Showing posts with label finally i do some coding. Show all posts
Showing posts with label finally i do some coding. Show all posts

Sunday, July 31, 2011

Overviewing the Government Web Presence

The Government released a list of about 440 current websites listed by department, which was fairly easy to turn into some PHP code. Hoping to release the code soon (once I've got Github working), but so far you can see what's below. Both projects try to get an overview of the Government's total web impression - it'd be interesting to repeat this, say, yearly to see what changes.

Click here for a page showing screenshots for all 400+ homepages

I also scraped the listed pages and did a bit of processing to turn the content into Wordles. OK, not terribly exciting. But I kind of like the idea of turning open data into "art".

Here's the front page content with some common and site-related words removed (click through for original):

Wordle: UK Government websites [unfiltered]

Here's the same data but with more common words removed by wordle.net:

Wordle: UK Government websites [filtered]

As I say, hope to post code and data soon, even though it's not much work to re-create... In the meantime, any suggestions welcome.

Monday, February 16, 2009

A Step-by-step Guide to Visualising Tweets

In response to psychemedia's request, I've put up a commented version of the code used to generate Wordles and Google Timelines.

The very rough and ready process was along the lines of:


  1. Run the Perl script to output Tweets into CSV format. These will be ordered in forwards chronological order. The script also generates a count for the number of tweets in each 10 minute time slot, to give some idea of activity over the course of time.

  2. Import the CSV into a fresh Google docs spreadsheet.

  3. I found it handy to duplicate this sheet, to play with subsets of the data e.g. just tweets for certain days.

  4. For the Wordles, I simply selected the relevant column (i.e. usernames, or tweet texts), and pasted into a decent text editor. I removed half the #ukgc09 tags for tweet texts, to stop it overpowering the rest. Then I just headed over to http://www.wordle.net/create, pasted the text, and played with formatting until I got something I like the look of.

  5. For the Google Timeline, I created a version of the sheet with 4 columns: tweet date/time (to become the X axis), number of tweets for this 10-minute time band (for Y axis = activity), tweet author and tweet content (for the notations). Then it was just a case of opening the "Insert gadget" menu, choosing the "Interactive Time Series Chart" gadget, and setting the Range to include all the data in these columns.

    I found it easiest to limit tweets to 3 days (otherwise the amount of notations causes the browser to get very slow), and to move the gadget to a separate sheet.

    Then I published the whole document as a web page (see the "Share" menu in the top right of the spreadsheet - you need to publish the data for the chart to work).


And that's it. As yet, I haven't found a way to publish just the gadget - Google have code to embed it in a page, but this doesn't seem to work.

I'm pretty sure there's a whole lot more you could do - I was just intrigued as to how activity varied through the weekend. (Perhaps it's good that the wifi on the day was down - I'm not sure how well that Time Series gadget scales...) The Wordles also seem quite a nice way to remember the day. Perhaps it might be possible to generate a similar, animated version to view word/author proliferation throughout a day as well?

Anyway, if you have any questions, leave a comment or get in touch via Twitter.

Monday, February 09, 2009

Playing with UKGC09 tweets and Wordle/Google

As I said before, UKGovCamp '09 was very inspiring - and got me thinking that in this day of mash-ups and widget-gidgets, one probably doesn't need to actually do much coding at all. I put my theory to the test, wrote a quick Perl script to chirp all the #ukgc09 tweets for the day of the event, the day before, and the day after, and shoe-horned the data into a couple of places which could be prettier if I had more time.

Here's a Wordle tag cloud of all tweets over the 3-day period:

Wordle: UKGovBarCamp09 tweets
(Click to view large, you'll need Java.)

For fun, here's a similar Wordle for the Tweet authors themselves:

Wordle: UKGovBarCamp09 Prolific Tweeters

Finally, here's a time-series plot of all the tweets over the 3 day period, on a Google graph so you can zoom in and out and click on tweets. The y-axis indicates roughly how much twitter activity there is in a 5-minute slot.

All good, clean fun.

Update Feb 16th: Here's the code I used to grab the #ukgc09 tweets - fairly simple Perl, requires a system with the JSON library and command line Curl installed (see code for links). I used a Mac with curl already installed, and added the JSON library using "perl -MCPAN -e 'install JSON'" from the terminal. YMMV.