comparing EPC certificates with git-diff # source
Our house just got a new EPC certificate. You can (maybe) check yours on https://www.gov.uk/find-energy-certificate.
I'm interested in easy ways to see change. Trying to compare the old and new webpages by eye is hard, which leads me to text-diffing. I can copy the contents of the website to a file and compare them that way. Let's. I did a similar thing a while ago with computer benchmarks.
I manually create two files by copying the interesting bits of the webpage, called 1
and 2
(because who has time for .txt
extensions). Then, I can run:
git diff --no-index -U1000 ~/1 ~/2 > diff.txt
cat diff.txt | sed -E 's#^\+(.*)#<ins>\1</ins>#' | sed -E 's#^-(.*)#<del>\1</del>#' | sed 's/^ //'
The latter command turns each into HTML by turning +
lines into <ins>
("insert"), -
into <del>
("delete"), and removing leading spaces on other lines. Then, I can whack the output into a simple HTML template:
<!DOCTYPE html>
<html>
<head>
<style>
body { background: black; color: white; }
pre { padding: 1rem; }
del { text-decoration: none; color: red; }
ins { text-decoration: none; color: green; }
</style>
</head>
<body>
<pre>
diff goes here...
<del>del lines will be red</del>
<ins>ins lines will be green</ins>
</pre>
</body>
</html>
The final output is something like this (personal information removed. don't doxx me.)
Energy rating DValid until
05 February 202505 February 2035Property type Mid-terrace house Total floor area
130 square metres123 square metres
This property’s energy rating is D. It has the potential to be C.This property’s energy rating is D. It has the potential to be B.Features in this property
Window Fully double glazed Good Roof Pitched, no insulation (assumed) Very poor
Roof Roof room(s), no insulation (assumed) Very poorRoof Roof room(s), insulated (assumed) GoodLighting Low energy lighting in 64% of fixed outlets GoodLighting Low energy lighting in all fixed outlets Very good Secondary heating None N/APrimary energy use
The primary energy use for this property per year is 303 kilowatt hours per square metre (kWh/m2).The primary energy use for this property per year is 252 kilowatt hours per square metre (kWh/m2).
Good job on us for having 100% low energy lighting fixtures, I guess...
Really, this is a complicated way to simplify something. I like simple things, so I like this.