Skip to content

Commit

Permalink
Merge pull request #224 from kilowatts-io/preview
Browse files Browse the repository at this point in the history
Preview
  • Loading branch information
BenjaminWatts committed Feb 25, 2024
2 parents 8184b28 + 1c26f6d commit 0c74ab6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/lambda/gb_snapshot/ng_dist/ng_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,17 @@ class NationalGridDistributionNetwork(BaseModel):
url: str

def run(self):
logging.debug(f"running NationalGridDistributionNetwork for {self.name}...")
logging.info(f"running NationalGridDistributionNetwork for {self.name}...")

resp = requests.get(self.url, headers={})
lines = resp.text.split("\r\n")
columns = lines[0].split(",")
rows = [line.split(",") for line in lines[1:-1]]
data = []
for row in rows:
data.append(dict(zip(columns, row)))
float_values = [float(x) if x != "" else None for x in row[1:]]
as_dict = dict(zip(columns[1:], float_values))
data.append({"Timestamp": row[0], **as_dict})
df = pd.DataFrame(data)
# set Timestamp as index
df.set_index("Timestamp", inplace=True)
Expand Down

0 comments on commit 0c74ab6

Please sign in to comment.