import csv
import json
from json import JSONEncoder
import math
from kafka import KafkaProducer
from kafka.errors import KafkaError
import matplotlib.pyplot as plt
TOPIC = "HRS-PART"
KAFKA_HOST = ['localhost:9092']
CSVFILE = 'hrs.csv'
def main():
_send_data()
def _send_data():
x = []
y = []
plt.xlabel('date - axis')
plt.ylabel('ratio - axis')
with open(CSVFILE, 'r') as f:
csvreader = csv.reader(f, delimiter=",")
next(csvreader)
for i in range(1000):
row = next(csvreader)
hrs = _make_json(row)
#datetime = hrs.datetime
datetime = hrs
ratio = hrs.ratio
y.append(ratio)
x.append(i)
plt.plot(i, ratio, marker=".")
plt.show()
def _make_json(row):
return HRS(row)
class HRS:
def __init__(self, row):
self.solarradiation = row[38]
self.Health_Risk_Score = row[45]
self.ratio = int(float(row[38])) / int(float(row[45]))
if __name__ == "__main__":
main()