rbfile
has an End-Of-Line (EOL) character (e.g. \r\n
) at the end. Strip it off:
rb = numpy.genfromtxt(rbfile.strip(), delimiter =',')
By the way, to debug problems with strings, it is often more useful to print the repr
of the string than the string itself:
print(repr(rbfile))
because the repr will show characters such as '\r\n'
more clearly.
file.readline()
does not strip EOF characters:
f.readline() reads a single line from the file; a newline character (\n) is left at the end of the string, and is only omitted on the last line of the file if the file doesn’t end in a newline. This makes the return value unambiguous;