I have created a csv file with two columns - the subject and the modules. and i want to print out all the modules for the same subject the csv file looks like this csvfile currently my code looks like:
import csv
subject = "Biology"
subject_module = []
with open("SubjectModules.csv", newline="") as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
subject_module_info = []
subject, module = row
while (row["Subject"] == subject):
subject_module_info.append(module)
subject_module.append(subject_module_info)
print(subject_module)
the output is just [] with no modules stored, how would i fix it?
This would be easier by using pandas.