I'm working on a project that allows users to define filters to sort data in a csv file. They can create as many or as few filters as they want so I am trying to create an if statement from a string that will get longer as users define more filters.
I have an output for my string variable which is this: row[0]=="6/1/2014 0:00:00"
So for simplicity sake I'll just hard code that into a variable name in the sample code below
The problem is that it doesn't correctly evaluate this if statement. It returns every row of the file.
f = open("somefile.csv", "r")
r = csv.reader(f)
statement = 'row[0]=="6/1/2014 0:00:00"'
for row in r:
if statment:
print(row)
Aucun commentaire:
Enregistrer un commentaire