Say I have thousands of 2D numpy arrays (each have shape 600x600) saved in a text file. I would like to read the file pixel by pixel for each array and operate on a 1D array of these pixels, without having to load in the whole file, since this would use a lot of memory.
For example, if this was in my file:
array([[1, 42, 98, ..., 2], ..., [89, 10, 76, ..., 2]]), array([[36, 79, 13, ..., 11], [81, 101, 34, ..., 109]]), ...
I would then want (for the [0][0] position) [1, 36, ...]
, for [0][1] I would want [42, 79, ...]
and so on. After I'm done operating on each 1D array, I'd like to delete it from memory and move on to reading the next one. Is this possible? It also doesn't have to be from a text file, if another type of file would work better.