I am new to python and I am converting Matlab code to Python. I have loaded the mat file which is a dictionary in Python. I can print the key names, but I cant understand how to show the types and size for the values
import scipy.io
import os
import sys
os.path.dirname(os.path.realpath(__file__))
path = os.getcwd();
filename = "\mnist_uint8"
fullname = path+filename;
print("Reading file:"+fullname)
try:
mat = scipy.io.loadmat(fullname)
except IOError as err:
print ("I/O error({0}): {1}".format(e.errno, e.strerror))
sys.exit();
else:
print("Successfully loaded mat file")
keys = mat.keys()
for key in keys:
print(key)
I need to see "key " + " type" + "size" which can be seen below
Try changing your last lines to:
for k in mat.keys():
if not k.startswith('__'):
print(k + " " + mat[k].dtype.name + " " + str(mat[k].shape))