importdata from dat file not picking the first cell

2 views (last 30 days)
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

Accepted Answer

dpb
dpb on 24 May 2017
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.

More Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!