问题
I know there are many answers but none of them solved my problem.
I have a .mat file and i want to export it's data to Csv.
The code that i tried:
import h5py
arrays={}
f=h5py.File('datafile.mat')
for k,v in f.items():
arrays[k]=np.array(v)
Which got me output in dictionary
{'#refs#': array(['0', '00', '00b', ..., 'zzj', 'zzk', 'zzl'], dtype='<U3'),
'MasterOperations': array(['Code', 'ID', 'Label'], dtype='<U5'),
'Operations': array(['CodeString', 'ID', 'Keywords', 'MasterID', 'Name'], dtype='<U10'),
'TS_CalcTime': array([[7.1010e-03, 2.5500e-04, 2.5300e-04, ..., 1.0800e-04, 9.5000e-05,
9.4000e-05],
[1.2238e-02, 8.0800e-04, 2.3500e-04, ..., 1.1400e-04, 9.6000e-05,
9.3000e-05],
-------and so on
and if i tried converting it into Dataframe then
ValueError: arrays must all be same length
I want export whole data into csv file without losing aur excluding any part.
Thanks
来源:https://stackoverflow.com/questions/62348024/how-to-read-data-from-mat-file-and-export-to-csv-in-python