Python
Running Reports
The Python source code for loading some data from a NEOpoint report and plotting it is shown below. We use the pandas and matplotlib libraries in this example. pandas is a data management and data analysis library and matplotlib is a plotting library; along with numpy, these are some of the most common libraries and come pre-installed in most python distributions.
# Imports
import pandas
import matplotlib.pyplot as plt
# CSV Link
url = 'https://neopoint.com.au/service/csv?key=*****§ion=0&f=101+Prices%5cDispatch+Prices+5min&period=Daily&from=2015-04-09&instances='
# Read Data and Plot
data = pandas.read_csv(url)
data.plot()
plt.show()The chart displayed from the above script is displayed below
Running SQL queries
The Python snippet for loading some data from an SQL query is shown below. Note the code uses the HTTP POST method because the query length will usually exceed the allowed URL length for a GET.
# Imports
import requests
import io
import pandas
import csv
# Query to run
query = '''select `SETTLEMENTDATE`, `RUNNO`, `REGIONID`, `PERIODID`, `RRP`, `EEP`,
`INVALIDFLAG`, `LASTCHANGED`, `ROP`, `RAISE6SECRRP`, `RAISE6SECROP`,
`RAISE60SECRRP`, `RAISE60SECROP`, `RAISE5MINRRP`, `RAISE5MINROP`,
`RAISEREGRRP`, `RAISEREGROP`, `LOWER6SECRRP`, `LOWER6SECROP`, `LOWER60SECRRP`,
`LOWER60SECROP`, `LOWER5MINRRP`, `LOWER5MINROP`, `LOWERREGRRP`, `LOWERREGROP`,
`PRICE_STATUS` from mms.tradingprice where SETTLEMENTDATE between '2018-11-01' and '2018-11-02' limit 0, 10000'''
# payload for POST request
url = 'https://neopoint.com.au/data/query'
data = { 'query': query, 'key':'*****', 'format':'csv'}
# Send HTTP request
response = requests.post(url, data=data)# Note do NOT use params=data as this serialises to the URL!
# Parse the response
data = pandas.read_csv(io.StringIO(response.text),
quotechar='\"',
delimiter=',',
quoting=csv.QUOTE_ALL,
skipinitialspace=True,
escapechar='\\')
# Remove spaces in the column names
data.columns = data.columns.str.strip()
print (data)Updated 16 days ago
Did this page help you?
