Created
May 1, 2019 21:02
-
-
Save jarvisms/3df538ffd79e7aa32ee703eced6308d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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