importdata from dat file not picking the first cell

2 vues (au cours des 30 derniers jours)
Kathy
Kathy le 24 Mai 2017
Réponse apportée : dpb le 24 Mai 2017
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

Réponse acceptée

dpb
dpb le 24 Mai 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.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Analysis dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by