If you are an electrical engineer, and want to know how to use Python to get data from the internet and display it, this post is for you.
(This is the first part of a series. By the end we’ll have written a Python script to display a chart of electricity market prices.
- All you need to analyse the electricity market pt 1
- All you need to analyse the electricity market pt 2
- All you need to analyse the electricity market pt 3
- All you need to analyse the electricity market final
Electricity prices in Australia have gone bananas
Since the carbon tax was introduced in Australia, the spot price for electricity has been very high. From $22 / MWh last month to over $50 / MWh so far (see the chart below). Whether this is a long term change, or just a temporary reaction, we don’t know. Instead of considering the complexities of market forces, we’re going to show you step by step exactly how to build your own Python program to display electricity prices, using Australia as an example.
|Very high electricity prices [Larger Size]
Feel free to take the code, and configure it for your own country’s system.
Downloading a zip file.
Australia’s electricity market operator (AEMO) keeps all of the market data online at http://www.nemweb.com.au/Reports/. The webpages are written in simple to understand HTML and link to zipped CSV files.
We’ll use Python to write a simple script that downloads a zipped file.
1 2 3 4 5 6 7 8 9 10
You may find that the link is expired, so you’ll get an error like this:
1 2 3 4 5 6 7 8 9 10 11 12 13
Got the error above? Change
ZIP_URL to match the url of a zip you can find on this
Unzip the downloaded file (the file is named
PUBLIC_PRICES.ZIP) and look at
the CSV file inside. You will find something like this:
1 2 3 4 5 6 7
The file is very long. In fact there are four separate CSV files crammed into this one long CSV file. In the next blog post we’ll examine exactly how to unzip the file you just downloaded with Python and then use one of these CSV files.
If you want to be emailed when the next blog is ready, just enter your email up the top →. We’ll only email you when a new blog is ready and with tips on becoming an advanced Python using power systems engineer.