Effacer les filtres
Effacer les filtres

Convert 1*1 struct file into a csv file

6 vues (au cours des 30 derniers jours)
Battery Fan
Battery Fan le 5 Avr 2021
Commenté : Battery Fan le 8 Avr 2021
Hi everyone,
I am new to Matlab. I want to convert the .mat file info a csv file with several columns, so that I can read into dataframe by Python.
It doesn't work with csvwrite command. Can anyone teach me how to do this? Thank you very much! I've attached the .mat file.
  2 commentaires
Sajid Afaque
Sajid Afaque le 5 Avr 2021
your struct contains main fields inside containing many subfields. what exaclty do you want to store in csv
Battery Fan
Battery Fan le 8 Avr 2021
Right. I have extract data and use the subfield name as the colunm name. Thank you.

Connectez-vous pour commenter.

Réponse acceptée

Anmol Dhiman
Anmol Dhiman le 7 Avr 2021
Hi Xueliu,
The structure that you shared is a nested one. Also you haven't specified the fieldnames that you wish to have in csv file. As the structure is nested , I suggest the best way is to write code for accessing structure elements. For that you can refer to this link.
The best way if the structure is not nested is to convert struct to table and then use writetable.
Hope it helps

Plus de réponses (0)


En savoir plus sur Data Type Conversion dans Help Center et File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by