New Metra schedule for Simplenote

As I mentioned last November, I have plain text versions of the Metra commuter rail schedule between Chicago and Naperville (where I live) saved in Simplenote. Metra made some changes to the schedule this week, so I updated and decided to make the files available in a GitHub repository.

On the iPhone, the schedules look like this:

Because Simplenote uses Helvetica, a proportional font, and doesn’t have adjustable tab stops (even if it did, there’s no tab key on the iPhone for entering them), the columns don’t line up perfectly, but they look OK. Until the iPhone gets a decent monospaced font, this will have to do.

There are six schedule files in the repository:

  1. Eastbound Monday through Friday
  2. Eastbound Saturday
  3. Eastbound Sunday
  4. Westbound Monday through Friday
  5. Westbound Saturday
  6. Westbound Sunday

Also in the repository is a Python script,, that I wrote to reformat the schedule times from the way they’re presented on the Metra web page.

I copy the schedule times from the box and paste them into a text editor. Generally, I get something that looks like this,

  08:40  10:40  12:40  02:40  04:40  06:40  08:40  10:40  12:40
Naperville  09:37  11:37  01:37  03:37  05:37  07:37  09:37  11:37  01:37

which some extra stuff at the beginning of each line that needs to be deleted to make it look like this:

08:40  10:40  12:40  02:40  04:40  06:40  08:40  10:40  12:40
09:37  11:37  01:37  03:37  05:37  07:37  09:37  11:37  01:37

Then I copy those lines and execute

pbpaste | python | pbcopy

which puts the reformatted schedule,

  8:40a            9:37a
10:40a          11:37a
12:40p            1:37p
  2:40p            3:37p
  4:40p            5:37p
  6:40p            7:37p
  8:40p            9:37p
10:40p          11:37p
12:40a            1:37a

onto the clipboard. It looks weird here, but that’s because you’re seeing it in a monospaced font, not Helvetica. Finally, I paste the times into the Simplenote webapp and do some minor editing. This usually consists of


 1:  #!/usr/bin/python
 3:  import re
 4:  import sys
 6:  # Collect the two rows of data.
 7:  start = sys.stdin.readline().split()
 8:  stop = sys.stdin.readline().split()
10:  # Change leading zeros to two spaces.
11:  start = [re.sub(r'^0', '  ', s) for s in start]
12:  stop = [re.sub(r'^0', '  ', s) for s in stop]
14:  # Print the data as two columns, using a simple heuristic for am/pm.
15:  ap = 'a'
16:  for i in range(0, len(start)):
17:    if start[i][0:2] == '12':
18:      if ap == 'a':
19:        ap = 'p'
20:      else:
21:        ap = 'a'
23:    print ' %s%s          %s%s' % (start[i], ap, stop[i], ap)

The AM/PM test is in Lines 17-21. This works pretty well for the Naperville-Chicago schedule and would probably be OK for other schedules, too. I thought about writing a routine that would work in every case, but it just wasn’t worth the effort. With this simple test, I only had to change a few as and ps.

If you’re a Simplenote user who lives in Naperville, the schedule files are pretty handy as is. If you’re a Simplenote user who lives in another town on the Chicago-Aurora line, or on another Metra line entirely, you can use to create your own Simplenote files.

If you’re not a Simplenote user, you should give it a try. It may be that Jesse Grosjean’s Dropbox-syncing suite of programs will end up working more smoothly, but until that happens, Simplenote is leading the pack.