0

When I run this:

import numpy as np

filename = "C:\\AV GIS\\ILS_measure\\sunshine_oct18.csv"
#filename = "C:\\AV GIS\\ILS_measure\\testcsv.csv"
data = np.loadtxt(filename, skiprows=0)
print(data.shape)

I get this:

 ValueError: could not convert string to float: b'1.94E+02,2.02E-03'

What does the 'b' mean before the "number-string" arguments?

I did hand-craft a .csv file to see if there was something peculiar to my real .csv data file, but even the simple .csv file produces the same error.

Andy Kellett
  • 41
  • 1
  • 5
  • 2
    The `b` means it's a byte-string. But the exception message is mostly telling you that you didn't choose the right delimiter (the [docs](https://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html) mention that it uses any whitespace as delimiter by default... but given the error message your csv uses comma). Does it work if you use `np.loadtxt(filename, skiprows=0, delimiter=',')`? – MSeifert Oct 18 '17 at 22:20
  • I should make it clear that even with values like 123.45, 234.56 in the hand-crafted .csv file, the 'b' still appears before '123.45, 234.56' in the error message. – Andy Kellett Oct 18 '17 at 22:25
  • Mseifert is exactly right - it was my non-choice of delimiter. Thank you very much! – Andy Kellett Oct 18 '17 at 22:27

0 Answers0