Merge two column in the table

Dear all, I have text file like this (attached file):
Date SR
2020/02/24 00:00:00.000 3.457785
2020/02/24 00:00:01.000 3.457785
2020/02/24 00:00:02.000 3.457785
2020/02/24 00:00:03.000 3.457785
I wanna convert it to table like this:
Date SR
2020/02/24 00:00:00.000 3.457785
2020/02/24 00:00:01.000 3.457785
2020/02/24 00:00:02.000 3.457785
2020/02/24 00:00:03.000 3.457785
But when I use the readtable. I got this result:
m=readtable('test.txt')
m =
4×3 table
Var1 Var2 Var3
______________ ________ ______
{'2020/02/24'} 00:00:00 3.4578
{'2020/02/24'} 00:00:01 3.4578
{'2020/02/24'} 00:00:02 3.4578
{'2020/02/24'} 00:00:03 3.4578
It spilit the column Date into 2 columns. Please give me the idea to fix this. Thanks so much.

 Respuesta aceptada

Star Strider
Star Strider el 17 de Mzo. de 2020

0 votos

One approach:
T1 = readtable('test.txt');
T1.Var1 = datetime(T1.Var1, 'InputFormat','yyyy/MM/dd');
T1.Var1 = T1.Var1 + T1.Var2;
T1.Var2 = [];
producing:
T1 =
4×2 table
Var1 Var3
____________________ ______
24-Feb-2020 00:00:00 3.4578
24-Feb-2020 00:00:01 3.4578
24-Feb-2020 00:00:02 3.4578
24-Feb-2020 00:00:03 3.4578

2 comentarios

quynh tran
quynh tran el 17 de Mzo. de 2020
Thank you so much. I got the answer
Star Strider
Star Strider el 17 de Mzo. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 17 de Mzo. de 2020
m.Date = m.Var1 + m.Var2;
m.SR = m.Var3;
m = m(:,4:5);

Categorías

Etiquetas

Preguntada:

el 17 de Mzo. de 2020

Comentada:

el 17 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by