diff options
author | Sam Chudnick <sam@chudnick.com> | 2023-06-03 13:37:00 -0400 |
---|---|---|
committer | Sam Chudnick <sam@chudnick.com> | 2023-06-03 13:37:00 -0400 |
commit | bd094f94faf210785d19e005907c6673dde6409d (patch) | |
tree | a4aca3c2783dcbf256758027d11b085fa48d5246 | |
parent | 18483e38bbdf92be7f2e33bf5dbb1c8ffc59f018 (diff) |
Fixed counting error in fill_gaps function
-rw-r--r-- | library.py | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
2 | import datetime, requests, json, pytz | 2 | import datetime, requests, json, pytz, sys |
3 | from geopy.geocoders import Nominatim, GeoNames | 3 | from geopy.geocoders import Nominatim, GeoNames |
4 | 4 | ||
5 | def get_lat_long(location): | 5 | def get_lat_long(location): |
@@ -72,9 +72,9 @@ def fill_gaps(values): | |||
72 | ret.append(val) | 72 | ret.append(val) |
73 | duration_hours = int((val["duration"].seconds / 3600) + (val["duration"].days * 24)) | 73 | duration_hours = int((val["duration"].seconds / 3600) + (val["duration"].days * 24)) |
74 | if duration_hours > 1: | 74 | if duration_hours > 1: |
75 | for _ in range(0, duration_hours - 1): | 75 | for i in range(1, duration_hours): |
76 | copy = val.copy() | 76 | copy = val.copy() |
77 | copy["time"] = val["time"] + datetime.timedelta(hours=1) | 77 | copy["time"] = val["time"] + datetime.timedelta(hours=i) |
78 | copy["duration"] = datetime.timedelta(hours=1) | 78 | copy["duration"] = datetime.timedelta(hours=1) |
79 | ret.append(copy) | 79 | ret.append(copy) |
80 | return ret | 80 | return ret |
@@ -347,5 +347,3 @@ def get_hourly_data(raw_data, end_time): | |||
347 | i+=1 | 347 | i+=1 |
348 | 348 | ||
349 | return ret | 349 | return ret |
350 | |||
351 | |||