This is my code thus far:
with open('in.csv', 'rb') as inp, open('out.csv', 'wb') as out:
writer = csv.writer(out)
for row in csv.reader(inp):
try:
floatRow= float(row[3].strip())
if floatRow > 180.0:
row[3] = floatRow - 180.0
writer.writerow(row)
else:
if floatRow < 180.0:
row[3] = floatRow + 180.0
else:
writer.writerow(row)
except ValueError,e:
writer.writerow(row)
The issue comes in the if/else statement. The 'if' statement works (as in the subtraction of 180), whereas the else statement will not work. The script runs fine, but it will eliminate all records with a value under 180 for some reason.
Where am I going wrong and how can I resolve this?