1

I wrote an algorithm using python and matplotlib that generates histograms from some text input data. When the number of data input is approx. greater than 15000, I get in the (append) line of my code:

mydata = []

for i in range(len(data)):
   mydata.append(string.atof(data[i]))

the error:

Traceback (most recent call last):
  File "get_histogram_picture.py", line 25, in <module>
    mydata.append(string.atof(data[i]))
  File "/usr/lib/python2.6/string.py", line 388, in atof
    return _float(s)
ValueError: invalid literal for float(): -a

can it be an error in python ? What is the solution ?

Thanks

2
  • 1
    Looks like something invalid in your data. Commented Mar 17, 2010 at 18:32
  • exactly, sorry, I got it, Drin less coffee :-P Commented Mar 17, 2010 at 18:38

1 Answer 1

1

That's a data parsing error:

>>> float("-a")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for float(): -a

Python data structure size if only limited by the available memory.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.