vendredi 18 octobre 2019

using csv value in if statement

the last line of my csv file is 10/18/19,11:52,22.8,999.4,40.1 so ((x[2])) will = 22.8

why cant i use this value in the if statement. I assume its how i am defining for the "if" statement to recognize the value of 22.8 but not sure what to google to find an answer and yes i am very very new to python

!/usr/bin/env python

import os import csv

import subprocess last_line = subprocess.check_output(["tail", "-1", "humidity1.csv"])

x = last_line.split(",")

print ((x[2]))

((x[2])) = y

if y > 100:

print("AAA")

else

print(BBB")

Aucun commentaire:

Enregistrer un commentaire