I have a CSV file like:
item1,item2
A,B
B,C
C,D
E,F
I want to compare this two column and find the similar content from the two columns item1 and item2. The output should be like this:
item
B
C
I have tried this code
with open('output/id.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile)
for line in csvreader:
if (line[0] == line[1]):
print line
else:
print("not match")
I am new to programming. I don't know what the logic should be and how to solve this problem. please help.
IndentationErrorin your code; is that all you're asking about?if line[1] == line[0]:.