1

I have some data in an array with 5 columns and a lot of rows.

I want to save this in a txt file by doing:

for i in range(rows):
    with open ('datos_practica.txt','a') as f:
        line=str(data[i,:])
        f.write(line)
        f.write('\n')

But instead of getting printing 5 columns in the txt file:

00 01 02 03 04

and so on........

It writes the last column below the first one

00 01 02 03

04

and so on....

Any clues for this issue? Thanks in advance.

1
  • 1
    I checked your code and it does output correctly. Please share the code of data and rows or just two lines of data. Commented May 18, 2020 at 16:54

1 Answer 1

3

Use this code instead:

np.savetxt("array.txt", np.array(your array))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.