Merging strings in a table
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
dormant
am 16 Mär. 2023
Kommentiert: dormant
am 21 Mär. 2023
I'm trying to merge two columns in a table. I tried this:
L = readtable( fileLog );
L2 = mergevars(L,["Var2","Var3"]);
But this end up with Var2 as a cell array.
L2 =
6×2 table
Var1 Var2
_________ _______________________
1.679e+09 {'Start'} {'ping' }
1.679e+09 {'Start'} {'copy' }
1.679e+09 {'Stop' } {'copy' }
1.679e+09 {'Start'} {'delete'}
1.679e+09 {'Stop' } {'delete'}
1.679e+09 {'Stop' } {'ping' }
How can I combine each row of Var 2 to be strings like "Start ping"? I tried using strjoin, but that gives me a single string.
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 16 Mär. 2023
Bearbeitet: Cris LaPierre
am 16 Mär. 2023
I would do this.
fileLog = "logData.csv";
L = readtable( fileLog, "TextType","string")
L2 = L(:,"Var1");
L2.Var2 = L.Var2 + " " + L.Var3
Weitere Antworten (1)
Voss
am 16 Mär. 2023
L = readtable( fileLog );
L2 = convertvars(mergevars(L,["Var2","Var3"]),"Var2",@(a)join(a," "));
Siehe auch
Kategorien
Mehr zu Text Analytics Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!