I'm trying to create matlab files from multiple files in a directory:
import os
from glob import glob
from numpy import*
from pandas import*
import scipy.io as sio
path = '/Volumes/Some file'
for filename in glob(os.path.join(path, '*.csv')):
df = read_csv(filename, delimiter = ';',...)
b= df.values #make dataframe into array
val = arange(8,13) # values with nan
b2 = delete(b,[val], axis = 1) #remove the nan values
c = sio.savemat('readcsv', dict(b=b2)) #convert to matlab
so what happens is that b2 in the loop when printed gives several arrays created from the files in the working directory. The problem is I don't know how to index each of the separate arrays outputted in the for loop, to create separate mat files. I tried numpy.ndenumerate:
D = array(b2)
for index, x in ndenumerate(b2):
print(index,x)
but this just treats the looped b2 as one big array and indexes them separately. I want to treat each of the arrays in b2 as a subarray, and create different mat. file for each subarray. I'm not sure which method to use.