Just read the file as it's given then parse the data columns...
t=readtable('couzi.csv','ReadVariableNames',0,'Delimiter',',');
t.Var1=str2num(char(strrep(t.Var1,'Cell ','')));
t.Var3=datetime(t.Var3,'Format','M-dd-yyyy HH:mm');
t.Properties.VariableNames={'Cell','Ens','Date','Val'}
t =
5×4 table
Cell Ens Date Val
____ ___ _______________ _________
1 13 3-22-2018 05:30 -0.024964
1 14 3-22-2018 05:35 -0.024964
1 15 3-22-2018 05:40 -0.024964
1 16 3-22-2018 05:45 -0.024964
1 17 3-22-2018 05:50 -0.024964
>>
ADDENDUM
As pedagogical note; a little more obtuse but perhaps "more MATLABy" solution to the first column could be
t.Var1=cellfun(@(s) sscanf(s,'Cell%f'),t.Var1);
to read and convert the actual cell content rather than strip/replace. Not sure if there would be any noticeable performance difference for large files or not.
Which leads to the alternate original solution to parse the file directly-- textscan can be used but readtable is more flexible in many ways altho for a very large file the resulting table may be somewhat slow in performance.
fmt='Cell%f%f%q%f';
c=textscan(fid,fmt,'delimiter',',','collectoutput',0);
will return
c =
1×4 cell array
{5×1 double} {5×1 double} {5×1 cell} {5×1 double}
where the time string is a cell array to convert to datetime.
Unfortunately, the '%{}D' time format scanning routine is broken for embedded space in the string between the date and time fields as is so common; the obvious
>> textscan(c{3},'%{M-d-yyyy HH:mm}D')
Error using textscan
Unable to read the DATETIME data with the format 'M-d-yyyy HH:mm'. If the data is not a time, use
text data.
fails miserably. One can workaround it with
>> t=textscan(strrep(c{3}(1),' ',''),'%{M-d-yyyyHH:mm}D')
t =
1×1 cell array
{[3-22-201805:30]}
and end up with an ugly, illegible output format; this, too, is fixable:
>> t.Format='default'
t =
datetime
22-Mar-2018 05:30:00
Best Answer