I have a csv file with the following data:
Rectangle Green Large
Rectangle Green Large
Rectangle Green Small
Rectangle Green Medium
Rectangle Green Small
Rectangle Blue Large
Rectangle Blue Large
Rectangle Blue Medium
Rectangle Orange Large
Circle Pink Small
Circle Pink Small
Circle Green Large
Circle Green Large
and my code for Python is the following:
import csv
with open("shapes.csv", 'rb') as csvfile:
rowreader = csv.reader(csvfile, quotechar = '|')
for row in rowreader:
if 'Large' and 'Green' in row:
print row
However the output I get is:
['Rectangle', 'Green', 'Large']
['Rectangle', 'Green', 'Large']
['Rectangle', 'Green', 'Small']
['Rectangle', 'Green', 'Medium']
['Rectangle', 'Green', 'Small']
['Circle', 'Green', 'Large']
['Circle', 'Green', 'Large']
I am trying to only display the records where Green and Large are in the row. Everything else should be excluded. I thought 'and' would complete this but it seems I am confused and going in the wrong direction.
What would be the correct way to implement this?