0

I have to save numpy.zeros((61, 33, 2, 7)) this matrix in txt file and also I have to read again. I looking for some solving. but could not solve the problem.

4
  • Why must this be a text file? What format do you expect exactly? Commented May 26, 2021 at 19:49
  • Can you not save it as a .npy? Commented May 26, 2021 at 19:51
  • I need to save this data and print it back into a matrix and use it. .txt not required. Commented May 26, 2021 at 19:52
  • Reshape it to 2d, and use savetxt and genfromtxt. Resahape again. There's no standard for 3 or 4d array text. Commented May 26, 2021 at 20:26

1 Answer 1

1

Since you say you don't need to save it as a .txt file, you can save it to a .npy like so:

import numpy as np

arr = np.zeros((61, 33, 2, 7))
np.save('/path/to/some/directory/some_file.npy', arr)
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.