python - Extracting specific values from .npy file -


i have .npy file of know (size, number of elements, type of elements, etc.) , i'd have way retrieve specific values without loading array. goal use less amount of memory possible.

i'm looking

def extract('test.npy',i,j):     return "test.npy[i,j]" 

i kinda know how text file (see recent questions) doing npy array allow me more line extraction.

also if know way scipy sparse matrix great.

thank you.

just use data = np.load(filename, mmap_mode='r') (or 1 of other modes, if need change specific elements, well).

this return memory-mapped array. contents of array won't loaded memory , on disk, can access individual items indexing array would. (be aware accessing slices take longer accessing other slices depending on shape , order of array.)

hdf more efficient format this, .npy format designed allow memmapped arrays.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -