I have been trying to do a linear search on a csv file and have written a simple algorithm to do so. It should print the amount of lines searched and the information
import csv
count = 1
with open('UKDATA.csv') as csvfile: #This opens the file as a csv file
reader = csv.DictReader(csvfile)
for row in reader:
first_name = row["first_name"]
last_name = row["last_name"]
if first_name == "Alethea" and last_name == "Mould" :
print(count, "rows searched")
print("Alethea Mould found on line",count+1)
print(row)
break
count += 1
Everytime I run this code it print out the information in a different order. Why does it do this Thanks