Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Downloading DCS meter readings to a CSV file
import pythondcs # From
import csv # Standard Library
dcs = pythondcs.DCSSession(DCSURL,USERNAME,PASSWORD) # Credentials as needed
with open("output.csv", "w", newline="") as outputcsv: # Adjust file as needed
csvwriter = csv.writer(outputcsv)
csvwriter.writerow(["Timestamp", "Demand", "Cumulative"]) # Make some headings
# ID and parameters as needed. Using iterator=True means each row is processed as it arrives
for row in dcs.get_readings(ID, start=STARTDATE, end=ENDDATE, iterator=True):
newrow = [
row["startTime"].strftime("%d-%m-%Y %H:%M:%S"), # Format the date how you want
row["periodValue"], # Get the other bits you want
csvwriter.writerow(newrow) # Write that row to the file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.