MATLAB: Importdata from dat file not picking the first cell

importdataMATLAB

Import data doesn't read the date from the first cell which is within a string. here is the code.
x = importdata('test.dat',',');
Here is the sample data
"2017-05-19 10:55:08",2,1,1,3.107,15.414,153.65,3.107,3.1,6.96,295.88,0.58,1.1,0.12,107.86,10.78,6.43,12.28 "2017-05-19 10:55:08",2,1,1,3.107,15.414,153.65,3.107,3.1,6.96,295.88,0.58,1.1,0.12,107.86,10.78,6.43,12.28 "2017-05-19 10:55:08",2,1,1,3.107,15.414,153.65,3.107,3.1,6.96,295.88,0.58,1.1,0.12,107.86,10.78,6.43,12.28
disp(x.data) gives the following
2,1,1,3.107,15.414,153.65,3.107,3.1,6.96,295.88,0.58,1.1,0.12,107.86,10.78,6.43,12.28 2,1,1,3.107,15.414,153.65,3.107,3.1,6.96,295.88,0.58,1.1,0.12,107.86,10.78,6.43,12.28 2,1,1,3.107,15.414,153.65,3.107,3.1,6.96,295.88,0.58,1.1,0.12,107.86,10.78,6.43,12.28
How to pick the first cell which contains the date value

Best Answer

The Tips section in the doc for importdata has the following...
Tips
To import ASCII files with nonnumeric characters outside of column or row headers, including
columns of character data or formatted dates or times, use textscan instead of importdata.
You can use the (relatively) new '%D' date format for the dates to convert directly to datetime class.