Last active
March 27, 2020 12:36
-
-
Save masyanru/195332e0ffe211efdf1db5da25f49f57 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 csv | |
import json | |
data = {} | |
final = [] | |
csvFilePath = 'h2_prod_ok.csv' | |
jsonFilePath = 'h2_prod_anomalies.json' | |
fieldnames = ('Series', 'Time', 'Value') | |
with open(csvFilePath) as csvFile: | |
csvReader = csv.DictReader(csvFile, fieldnames, delimiter=';') | |
for row in csvReader: | |
# leave only every minute | |
if '00+03:00' in row['Time']: | |
digit = row['Value'].split('.', 1)[0] | |
data = {'timestamp': row['Time'], 'value': digit} | |
# print(row['Value']) | |
final.append(data) | |
print(json.dumps(final)) | |
# convert csv into json for anomaly detecttion | |
# json_data = '{"maxAnomalyRatio": 0.45, "granularity": "minutely", "sensitivity": 90, "series": ' + json.dumps(final) + '}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment