Saving a large matrix in to a .txt file in python

Viewed 6746

I would like to know what is the easiest way to save a large matrix, in my case with 640x640 elements, into a .txt file where it is easier to overview it.

I've been trying to convert every single element in to a string and then save it, but I never managed to get a correct, matrix-like organised .txt file.

So I would like to save the all the elements in the exact same order, maybe I would add an additional row and column to enumerate the rows (from -320 to +320) and columns.

I guess this is a common thing with some of you, that do this on a regular basis, so I would like to know, if anyone would be willing to share his knowledge and maybe show an example with a random matrix...

Luka

3 Answers
Related