0

I've this error message TypeError: 'numpy.float64' object is not iterable when y execute my .py.

It occur in:

file=open("results.txt","a")
    for i in ConcatRPH:
        for j in i :
        file.write(j)
    file.write("\n")
file.close()

ConcatRPH is a large array about 2 million line by 3 column which containt floats like -0.00161894927736417and i need to write them in a txt file. I don't know why I have this error ... Do you have any idea ?

1
  • Are you sure that you've got the indentation correct? And perhaps this post discusses what you want. Commented Mar 13, 2019 at 10:36

1 Answer 1

0

The only possible reason is that ConcatRPH does not have the shape you think it has. So, most likely, the i you get from for i in ConcatRPH is a float, and you get an error on the following line. Print i to make sure.

However, if you really want to store a table to a text file (not doing it for practice), better use numpy.savetxt.

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

1 Comment

Great ! It work with the numpy.savetxt. Thank you blue_note

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.