MATLAB Answers

Could someone help me import data from a .csv file?

4 views (last 30 days)
Lennaert on 3 Oct 2012
I am having difficulties importing data from a csv file. Below you can find a copy of the first three lines. The first, a headerline and the second two are just the data. I have tried csv read and text read but seem to be running into problems. Could someone please tell me how to do it properly and explain why?
Kind regards,
file: 'summary.csv'
DateTime,IR Temp,ECG Qual,Belt Qual,EDR Qual,Imp Qual,PWI Conf,ECG HR,EDR BR,Belt BR,Imp BR,HR consist,BR consist,Core Serial,Core Temp,Patch Serial,Patch Temp,Vbat,Body Pos,Motion,Nonin SpO2,Nonin HR,Thermistor Ambient,Ambient IR,Thermistor Skin
19/09/2012 16:39:48.266,26,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Upright,MovingFast,-1,-1,-1,23.5,-1,
19/09/2012 16:39:53.266,26,-1,-1,-1,-1,-1,307.2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Side,MovingSlowly,-1,-1,-1,23.5,-1,
NOTE FIRST Column of data looks like: dd/mm/yyy hh:mm:ss:ms

Accepted Answer

owr on 3 Oct 2012
If you have the Statistics Toolbox,try:
ds = dataset('File','summary.csv','Delimiter',',');
The fact that you have mixed types in your columns (numeric and text) makes dataset arrays the ideal container for your data.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by