Code to Grab your Maritime Electric Transactions

My next logical step after discovering the treasure-trove of data available to customers in Maritime Electric’s customer portal was to create a simpler way of pulling that information out of their website and into a format that’s easier to analyze and visualize.

In an ideal world there would be a Maritime Electric API that would allow me to do something like:

wget http://data.maritimeelectric.com/transactions.xml

But there’s not. So some scripted login voodoo, followed by some screen-scraping voodoo, is required to pull the data off in a useful format.

And so that’s what I did. Over at GitHub you can grab the code and, assuming you’re on a suitably-equipped computer (a Mac works well for this with nothing additional to install), you can turn your complete Maritime Electric transaction history into a CSV file, suitable for import into a spreadsheet, in one easy step. Here’s a quick step-by-step:

  1. Grab a ZIP file of the latest pei-energy code.
  2. Unzip the resulting file, which will be named something like reinvented-pei-energy-2bec180.zip.
  3. From the command line, move to the maritime-electric/transactions folder inside the code you just unzipped.
  4. From the command line, issue the following command, substituting the email address and password you use to login to the Maritime Electric Customer Portal:
php maritime-electric-dump.php email password

The result will be a file, in your home directory, called maritime-electric-accounts.csv that lists the service addresses attached to your account, and one file, named [account-number].csv, for each service address containing the complete transaction history for that address.

You can then load those files into any old spreadsheet application to search, sort and visualize the data:

Working with Electricity Bill Data in Numbers

Comments

Todd's picture
Todd on May 5, 2011 - 14:19 Permalink

Pulled my transaction data into Excel last night from the Maritime Electric site [the old fashioned copy/paste way, I’m afraid :-) ] and played around with the sorts and filtering. Then tried some trending graphs. Very interesting to visualize this history.

Thanks for the tip, Peter!

Peter Rukavina's picture
Peter Rukavina on May 5, 2011 - 18:53 Permalink

I fixed a bug in the PHP&#160code that was causing only every second transaction to be exported into the CSV file.


Note, was well, that the line-item “PEN Charge” is what appears on printed bills as “Interest charge on unpaid balance”.

Peter Rukavina's picture
Peter Rukavina on May 5, 2011 - 19:01 Permalink

Here’s a graphic illustrating the mapping between what gets exported into the CSV file and what appears on your printed Maritime Electric bill:


<img src=”http://media.ruk.ca/images/Bil…” alt=”“/>

Peter Rukavina's picture
Peter Rukavina on May 5, 2011 - 19:11 Permalink

Some insights from Martin Spindler on customer reading of our own digital electricity meters:


<object width=”100%” height=”81”>
<param name=”movie” value=”http://player.soundcloud.com/p…”/>
<param name=”allowscriptaccess” value=”always”/> <embed width=”100%” height=”81” allowscriptaccess=”always” src=”http://player.soundcloud.com/p…” type=”application/x-shockwave-flash”></embed> </object>