Systeme D

15 September 2006

Timetables on iPod

While furiously pacing Birmingham New Street last night, waiting for a seriously delayed Virgin train to Oxford, I had one of those brainwaves that doubtless makes a lot of sense to me while everyone else thinks "uh, why?".

To get from Birmingham to Charlbury, for example, you have at least three options. You can go from New Street to Oxford and then to Charlbury, which is the route that the online journey-planner always tells you. Or you can go via Worcester, which is always cheaper and sometimes quicker. Or if you're feeling particularly l337, you can sprint across to Moor Street in two minutes flat, jump into the cab of the last southbound train of the night, changing at Banbury for Oxford, and so on, which once saved my bacon after another (ha!) Virgin failure on the way back from Edinburgh.

The only sane way to work out these options is to look at the printed timetable. National Rail Enquiries won't quote you any times which involve connections of less than seven minutes or so. Unfortunately, (a) the printed timetable weighs a ton, (b) it's being withdrawn. And yes, you can subscribe to a PDA version, but why should you have to buy a PDA and an annual subscription just for basic data?

Hence my 'umble brainwave:

  • Use CAM::PDF and some clever Perl to scrape train times from each company's downloadable PDFs.
  • Reformat into a file for each possible direct connection (e.g. Birmingham-Oxford, Birmingham-Worcester, Oxford-Charlbury) in the area you're interested in. Place them within a hierarchical folder structure, e.g. Weekdays/Oxford/Charlbury.
  • Upload to iPod in notes format.

So does that mean I need to buy myself an iPod? What a shame.


Comments

You don't need to scrape the timetables from website PDFs. The approach I used for the mySociety travel-time maps was to buy a copy of RailPlanner, an off-the-shelf desktop route planning program, for about forty quid (includes a year's worth of updates to the timetable) and then write code to script it. This does require writing Win32 code (and, worse, running Windows), but on modern hardware it's nice and fast -- you can search for all routes from one station to all the others on the network in a few minutes. Drop me a line if you want the code for the scraper (it's GPL).

Posted by Chris Lightfoot on 23.9.06 13:48

Interesting thought. I'm tempted to try the PDF parsing thing because a) I'd like to incorporate bus times, too, and b) I don't have Windows, but it sounds like a sensible idea. I wonder if the RailPlanner guys would be interested in incorporating iPod notes into their core product?

Posted by Richard Fairhurst on 28.9.06 12:44


Add a comment

Your name:

E-mail address: 

Comment:

your comment. (E-mail addresses will not be visible, but a server-based mail link will be provided. To guard against spam, no comments which include 'http' or 'www' will be published.)