MATLAB: Reading a csv file containing not only numerical data

csvreadheadersimport csv

Hi,
I have this sort of file.csv
Date Time Voltage L12 Min Voltage L12 Avg Voltage L12 Max Voltage L23 Min Voltage L23 Avg
06/04/2015 16:33:01 745ms 150.660 150.740 150.840 150.560 150.660
06/04/2015 16:33:02 245ms 150.760 150.780 150.800 150.460 150.560
06/04/2015 16:33:02 745ms 150.720 150.740 150.740 150.620 150.720
06/04/2015 16:33:03 245ms 150.620 150.680 150.740 150.580 150.680
As you see with different type of data. I only need to import the numerical part and so I am using the following command
filename = 'Trial1.csv';
M = csvread(filename,3,3)
I have tried with different number of rows an column in order to avoid non numerical data, but I always receive this error message.
Error using dlmread (line 139)
Number of HeaderColumns is greater than number of columns in file.
Error in csvread (line 48)
m=dlmread(filename, ',', r, c);
Error in EnergyReading_20150627 (line 8)
M = csvread(filename,3,3)
It looks like I have different number of columns but is actually a perfect rectangular matrix on the csv file.
Please any suggestions?

Best Answer

Use the textscan function to read it instead. Without your actual file to experiment with, and not knowing exactly what columns you want to import, I can’t write a specific textscan call.
Related Question