I have the following csv file:
Value1,Value2,Value3,Value4
11,12,27,28
5,6,101,102
111,112,55,56
1,7,33,34
3,4,55,57
I want to print lines if Value1 & Value2 are consecutive AND Value3 & Value4 are consecutive. The desired answer would be:
11,12,27,28
5,6,101,102
111,112,55,56
I tried something like this but it didn't work
f = open('test.csv', 'rU')
for line in csv.reader(f):
if line [1] == line [0] + 1 & line [4] == line [3] + 1:
print line
f.close
Any help is appreciated. Thanks!
&
toand
, the first is bitwiseAND
which you don't want, you want logicalAND
. – Cory Kramer