I have a csv file in below format:
TestCase and Flag are the column names.
Now in order to read all the rows of above csv file,i have written below code:
with open('location of above csv file', 'r+') as file:
data = csv.DictReader(file, dialect='usercredentials')
for row in data:
testcase = row['TestCase']
flag = row['Flag']
return testcase, flag
In the for loop, you are replacing the value of the testcase and flag variables in each iteration and finally you are returning values from the last row. You probably want to use a dict or a list in which to append those values in each iteration and finally return those.