Hi I have two set of columns in the text file column 1 is yyyy-mm-dd and column2 is precipitation. I want to extract the precipitation value only for April through August. In order to get that, I split the line and extract only month from column 1. Then try to make dictionary for month and precipitation and use a if statement to match the months and append the corresponding precipitation value in an empty array.
While doing that, I am getting an "invalid token" error in my if statement for month==08 in the code below:
Code:
file1 = open("test.txt","r")
Growing-period=[]
Intermediate-period=[]
Dormant-period=[]
for line in file1:
line2 = line.split()
WQ = line2[1]
month = line2[0].split("-")[1]
dct1={month:WQ}
for k,v in dct1.item():
if (month==04 or month==05 or month==06 or month==07 or month==08):
Growing-period.append(dct[v])
print Growing-period
Any help/direction would be appreciated! Thanks,