I have a program that takes file code as input in this case '19E071OE1' and it needs to print out all the rows that have that value in its 4th column it kind of works but I have to input file code for each individual row. My question is how do I make it scan all rows at once and print them out?
Code:
import csv
def ime_predmeta():
imepred = input("Unesi kod predmeta: ")
if imepred.isupper():
return imepred
else:
print("Unos nije validan probajete opet!")
return ime_predmeta()
def ucitavanjerasp1():
file = open('raspored1.csv', "r")
reader = csv.reader(file, delimiter=',')
for row in reader:
if ime_predmeta() in row[3]:
print(row)
def main():
ucitavanjerasp1()
if __name__ == '__main__':
main()
The bad output:
Unesi kod predmeta: 19E071OE1
['0', '08:00', '11:00', '19E071OE1 [OO 2019] P1']
Unesi kod predmeta: 19E071OE1
['0', '11:00', '14:00', '19E071OE1 [OO 2019] P2']
Unesi kod predmeta: 19E071OE1
['0', '14:00', '17:00', '19E071OE1 [OO 2019] P3']
Unesi kod predmeta: 19E071OE1