lundi 9 mars 2020

Python, if statements on loops

I am having an issue exluding some data from my python script, beginner learning here!

Currently I have a csv file with c. 19 columns, I need to print col 0, 1, 8, 18 - which I have successfully.

Column 8, has a value of 0.00, or above. I would like the script to exclude these lines and not print them. I have attempted the if statement, but the below code just executes and prints all lines - doesnt only print those 0.01 or above.

Current code:

import csv

m = open('data.csv')
csv_m = csv.reader(m)

for row in csv_m:
        if row[8] >= 1:
                print(row[0],row[1],row[8],row[18],)

Aucun commentaire:

Enregistrer un commentaire