Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14215

How do I change a value in a .npz file?

$
0
0

I want to change one value in an npz file.

The npz file contains several npy's, I want all but one ( 'run_param' ) to remain unchanged and I want to save over the original file.

This is my working code:

DATA_DIR = 'C:\\Projects\\Test\\data\\'ass_file = np.load( DATA_DIR +'assumption.npz' )run_param = ass_file['run_param']print ass_file['run_param'][0]['RUN_MODE']ass_file['run_param'][0]['RUN_MODE'] = 1        (has no effect)print ass_file['run_param'][0]['RUN_MODE']print run_param[0]['RUN_MODE']run_param[0]['RUN_MODE'] = 1print run_param[0]['RUN_MODE']

This produces:

0001

I can't seem to change the value in the original npy.

My code to save afterward is:

np.savez( DATA_DIR +'assumption.npz', **ass_file )   #ass_file.close()

How to make this work?


Viewing all articles
Browse latest Browse all 14215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>