I'm pulling in data using urllib (Python 3) that arrives looking like this:
b'\n 9 27 70.40 43.40 0.00 15.90 3218.5 \n 9 28 74.90 43.70 0.00 18.30 3236.8'
Converting this to string it ends up like this:
"\\n 9 27 70.40 43.40 0.00 15.90 3218.5 \\n 9 28 74.90 43.70 0.00 18.30 3236.8"
I'd like to use numpy.genfromtxt to build an array, but I can't get io.StringIO to parse the newline characters. When I use:
table = io.StringIO(match.group(1), newline=r"\\n") # or newline=r"\n"
I get an error message:
ValueError: illegal newline value: '\\\\n'
I've also tried keeping the data in the native bytes format and using io.BytesIO but I have the same problem.