Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import pythondcs # From https://github.com/jarvisms/pythondcs
import csv # Standard Library
dcs = pythondcs.DCSSession(DCSURL,USERNAME,PASSWORD) # Credentials as needed
targets = [123,456,789] # List of meters you want details for
with open(r"MetersDetails.csv", "w", newline="") as outputcsv: # Adjust file as needed
csvwriter = csv.writer(outputcsv)
for id in targets:
meter = dcs.get_meters(id)
output = [
meter["id"],
meter["name"],
meter["meterTypeName"],
meter["serialNumber"],
None, # Deliberately leave a space for clarity
"REGISTERS:",
*[item for reg in meter["registers"] for item in (reg["id"], reg["name"], reg["unit"])],
# The above line create 3 coloumns with reg-id, name and unit listed for each.
# If there's only 1 register, jsut the 3 coloumns will be written.
# If there are 10 registers, then there will be 30 coloumns.
]
csvwriter.writerow(output)
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.