Saman
Saman

Reputation: 49

'list' object has no attribute 'items' for saving list of array as mat file

I want to save a list of NumPy array as a mat file but raised with error 'list' object has no attribute 'items'. You can see my try below:

import numpy as np
import scipy.io

output=[]
for i in range(10):
  a=np.random.randint(0,100,size=(60,60,4))
  output.append(a)
scipy.io.savemat('test.mat', output)

Upvotes: -1

Views: 443

Answers (1)

Saman
Saman

Reputation: 49

Here is the answer:

import numpy as np
import scipy.io

output=[]
for i in range(10):
  a=np.random.randint(0,100,size=(60,60,4))
  output.append(a)
scipy.io.savemat('test.mat',  mdict={'my_list': output})

Upvotes: 1

Related Questions