Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bulk rename DCS Meters according to a CSV file
# Note this uses advanced (and unsupported) features, hence pythondcsPRO
import pythondcspro as pythondcs # From
import csv # Standard Library
dcs = pythondcs.DCSSession(DCSURL,USERNAME,PASSWORD) # Credentials as needed
backup={} # Keep original copies as backup
with open("input.csv", newline="") as inputcsv: # Adjust file as needed
# File format is literally just "<id>,<name>" on each row
csvreader = csv.reader(inputcsv)
for id,name in csvreader:
id = int(id)
meter = dcs.get_meters(id) # Get the current copy (Read-Modify-Write)
backup[meter["id"]] = meter.copy() # Keep a backup
meter["name"] = name # Just edit this, keep all other details the same
meter = dcs.update_meter(meter) # Push it back to the server
print(meter["id"], meter["name"])
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.