Martin
Martin

Reputation: 11

How to export datasets to .csv file from the field variables stored in .mat files

I am trying to import the data from a complex .mat file where 4 fields variables are stored. I need to store the field variables (dataset one) in csv format. I am unable to store the data.

import scipy.io # to load mat files
import seaborn as sns
import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plte here
```

```
for root, dirs, files in os.walk("ambient_201810", topdown=False):
    for file_name in files:
        path = os.path.join(root, file_name)
        print(path)
```

path = r'ambient_201810\ambient_20181002_160000.mat'
matfile = scipy.io.loadmat(path) ## Import to a python dictionary
matfile.items() # Look at the dictionary items

```
list(mat.keys())
key_name = list(mat.keys())[3]
key_name
DE_data = mat.get(key_name)
DE_data
```
df_temp = pd.DataFrame({'DE_data':np.ravel(DE_data)})`

# dataset link: [https://zenodo.org/record/3745914#.Y1__dHZByUn]

Upvotes: 1

Views: 97

Answers (0)

Related Questions