Problem
I have two files i have to read and extract data from. The data contains these strings:
162, 520,20121028, -28, 0
162, 520,20121029, 54, 0
162, 520,20121102, 48, 0
162, 520,20121103, 33, 0
162, 520,20121104, 12, 0
I need to unpack the data into a variable which i want to add to a list so that i can analyze it.
What i tried
hoog ='/Users/arkin/programming/TX_STAID000162.txt'
data_laag = open('/Users/arkin/programming/TN_STAID000162.txt')
temp = []
for line in data_laag:
niks = line.split(',')
temp.append(niks[3])
i wanted to give the third string the name temp and append them to a list however i get the error
index out of range
the result of the split is:
[' 162', ' 520', '20121130', ' -28', ' 0\r\n']