Untitled
Anonymous
python
10/13/2024 8:08 PM
736 B
24
Indexable
import csv
def csvFilter(filename, requiredCalories):
# Open the CSV file
tupleOutput = ([], [])
with open(filename, mode='r', newline='') as file:
reader = csv.reader(file, delimiter=',')
first = True
# Read and print each row
for row in reader:
if first:
first = False
continue
if len(row) > 4 and row[2] == "H":
tupleOutput[0].append(row[0])
if len(row) > 4 and int(row[3]) < requiredCalories:
tupleOutput[1].append(row[0])
return tupleOutputEditor is loading...
Leave a Comment