read a .txt file
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Carmen Juliana Gonzalez
le 10 Sep 2021
Réponse apportée : Mathieu NOE
le 10 Sep 2021
Hi,
I have a .txt file containing 6 columns of different data types separated by white spaces.
This is how the data of the .txt file looks like:
02/06/2021 10:54:08 Z 00009 z 00008
02/06/2021 10:54:08 Z 00009 z 00009
02/06/2021 10:54:08 Z 00009 z 00009
I made the following script, but it is not exactly what I need.
filename = '0-3000.txt';
fileID = fopen(filename,'r','n');
sprinIR_data = [];
sprinIR_data = textscan(fileID,'%{dd/MM/yyyy}D %{hh:mm:ss}T %s %f %s %d' );
What I need is to make a table with the second column (the time) and the 4th and 6th columns wich are the numerical values of the measurement.
I do not know how to manage the time type of data.
Thank you very much in advance for your help!
Kind regards,
Juliana
0 commentaires
Réponse acceptée
Mathieu NOE
le 10 Sep 2021
hello
have you tried to work with tables - using readtable ?
filename = '0-3000.txt';
T = readtable(filename);
C = table2cell(T);
gives :
T =
3×6 table
Var1 Var2 Var3 Var4 Var5 Var6
__________ ________ _____ ____ _____ ____
02/06/2021 10:54:08 {'Z'} 9 {'z'} 8
02/06/2021 10:54:08 {'Z'} 9 {'z'} 9
02/06/2021 10:54:08 {'Z'} 9 {'z'} 9
C =
3×6 cell array
{[02/06/2021]} {[10:54:08]} {'Z'} {[9]} {'z'} {[8]}
{[02/06/2021]} {[10:54:08]} {'Z'} {[9]} {'z'} {[9]}
{[02/06/2021]} {[10:54:08]} {'Z'} {[9]} {'z'} {[9]}
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Tables dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!