Calling numpy.loadtxt without specifying the optional max_rows parameter results in TypeError.
Example program:
import sys
import numpy
filename = 'test_max_rows'
fic = open(filename,'w')
for i in range(10):
fic.write("1 2 3 4\n")
fic.flush()
#Works
a = numpy.loadtxt(filename, max_rows=10)
print(a)
#Crashes with TypeError: 'NoneType' object cannot be interpreted as an int
b = numpy.loadtxt(filename)
print(b)
The complete trace is:
File "venv-graalpython/lib/python3.8/site-packages/numpy-1.16.4-py3.8-linux-x86_64.egg/numpy/lib/npyio.py", line 1141, in loadtxt
for x in read_data(_loadtxt_chunksize):
File "venv-graalpython/lib/python3.8/site-packages/numpy-1.16.4-py3.8-linux-x86_64.egg/numpy/lib/npyio.py", line 1055, in read_data
line_iter = itertools.islice(line_iter, max_rows)
TypeError: 'NoneType' object cannot be interpreted as an int