I am trying to calculate the sum of produced power in a CSV file.
- This schould be the last line of the file, second value - first line of the file, second value
or
Sum of every value at the end of the line..
07:15;4719.852;0.036
07:20;4719.857;0.060
07:25;4719.863;0.072
.
.
08:30;4720.399;0.924
I've noticed that is seperatet by ";" in stead of a ","
Since I cant figure option 1 out I've gone in calculating the sum of every line.
First is change the ";" in ","
cat /home/LoadLive/day.csv | tr ";" "," > /home/LoadLive/day1.csv
Then I use the python script
import csv
with open('/home/LoadLive/day1.csv', 'r') as f:
total = 0
for row in csv.reader(f):
total += float(row[2])
print('The total is {}'.format(total))
And the result is "The total is 0.9600000000000001"
Where does the 000000001 comes from? and can I do this in a better way?
Tanks