I can't figure out why my below code won't assign a new value to the nth row inside the for loop. As far as I know, the way I index the b matrix should be correct but it seems like the count variable won't update for each iteration. The print statements serve only as a way of checking what is going on.
I assume that it's pretty simple, so I would highly appreciate if one could point out were I'm wrong.
#!/usr/bin/python
import sys
#from string import maketrans
#import re
import numpy as np
lines = sum(1 for line in sys.stdin)
b = np.zeros((lines,2))
count = 0
for line in sys.stdin:
line = line.strip()
myline = line.split(",")
Depart = myline[3]
DepartDelay = float(myline[6])
if DepartDelay<0:
DepartDelay=0
b[count,0] = Depart
b[count, 1] = DepartDelay
count = count + 1
print(count)
print(b)
print(count)
I use the following command to execute the code within the terminal of Ubuntu.
cat sample.txt | mapper.py
which is why there as such aren't specified any data/text file.
In advance, thank you!