Skip to content

Instantly share code, notes, and snippets.

@jarvisms
Created May 1, 2019 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarvisms/3df538ffd79e7aa32ee703eced6308d2 to your computer and use it in GitHub Desktop.
Save jarvisms/3df538ffd79e7aa32ee703eced6308d2 to your computer and use it in GitHub Desktop.
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