I am new to python programming. I need to read contents from a csv file and print based on a matching criteria. The file contains columns like this:
abc, A, xyz, W
gfk, B, abc, Y, xyz, F
I want to print the contents of the adjacent column based on the matching input string. For e.g. if the string is abc it should print A, and W for xyz, and "no match" for gfk for the first row. This should be executed for each row until the end of the file.
I have the following code. However, don't know to select the adjacent column.
c= ['abc','xyz','gfk']
with open('filer.csv', 'rt') as csvfile:
my_file = csv.reader(csvfile, delimiter=',')
for row in my_file:
for i in c:
if i in row:
print the contents of the adjacent cell
I would appreciate any help in completing this script.
Thank you