S
S
Sergey01012020-06-30 14:04:41
Python
Sergey0101, 2020-06-30 14:04:41

How to append a numpy array to a text file without overwriting?

np.savetxt()overwrites the file.
Is it possible somehow to add a one-dimensional array to a file without overwriting the file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cython, 2020-06-30
@Sergey0101

The a flag of open allows you to append content

with open("file.txt", "a+") as f:
    np.savetxt(f, <массив>)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question