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
### WARNING: READ CAREFULLY BEFORE ATTEMPTING ### | |
# | |
# Officially, this is not recommended. YMMV | |
# https://www.raspberrypi.com/news/bookworm-the-new-version-of-raspberry-pi-os/ | |
# | |
# This mostly works if you are on 64bit. You are on your own if you are on 32bit or mixed 64/32bit | |
# | |
# Credit to anfractuosity and fgimenezm for figuring out additional details for kernels | |
# |
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 sqlite3 | |
from datetime import datetime | |
# Connect directly with the database file and make a "connection" object | |
conn = sqlite3.connect(r"/home/pywws/weather-data/pywws.db") | |
start = datetime(2020,1,1).timestamp() # Timestamp in seconds 1577836800.0 | |
end = datetime(2020,2,1).timestamp() # Timestamp in seconds 1580515200.0 | |
# SQL query with named variables :start and :end which are supplied by a dictionary and substituted in place. |
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
#!/usr/bin/env python3 | |
import datetime | |
import os | |
import os.path | |
import shutil | |
def striptime(dt): | |
try: | |
return datetime.datetime.strptime(dt,"%Y-%m-%dT%H-%M-%S") # Convert it | |
except ValueError: # If it doesn't look like a date, return None (boolean False) |
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
# Note this uses advanced (and unsupported) features, hence pythondcsPRO | |
import pythondcspro as pythondcs # From https://github.com/jarvisms/pythondcs | |
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: |
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) |
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 | |
from datetime import date | |
dcs = pythondcs.DCSSession(DCSURL,USERNAME,PASSWORD) # Credentials as needed | |
targetmeters = [123,456,789] # List as many IDs as you need. In this case all assumed to be registers. | |
with open("output.csv", "w", newline="") as outputcsv: # Adjust file as needed | |
csvwriter = csv.writer(outputcsv) | |
### Output in "Periodic Channel Export" format as needed to import into TEAM Sigma aM&T software, coloumns are: |