importdata from dat file not picking the first cell
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
dpb
2017-5-24
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!