CSV Variable Names truncated on 2 rows how to append
Mostrar comentarios más antiguos
Hello!
I am trying to import a large number CSV files generated from another piece of software that has an unfortunate bug.
Instead of writing all the variable names (in this example 'Var') on one row, it will eventually truncate a variable name and continue on a new line. Example below:
Var1,Var2,Var3,V
ar4,Var5,Var6
Dat1,Dat2,Dat3,Dat4,Dat5,Dat6
Assuming I have no control over the data origin, how do I append/attach the 2nd row of variable names to end of the first to restore data continuity? (so that I may eventually use readtable or importdata without errors)
The row numbers for the trunkated variable names is always the same as they follow a header. It seems like for the files that I'm currently processing the truncation position is also consistant but I can't guarantee that it will stay like that forever
The end goal is to create a structure array X.Var1 ... VarN. A workaround is also acceptable.
Doing it manually is not an option as there are too many of them
Thank you!
1 comentario
Umberto Voci
el 13 de En. de 2020
Editada: Umberto Voci
el 13 de En. de 2020
Respuesta aceptada
Más respuestas (1)
Jyotsna Talluri
el 22 de En. de 2020
0 votos
You can read the CSV files using readtable function and then you can modify the data as required
Refer to the below link
1 comentario
Umberto Voci
el 22 de En. de 2020
Editada: Umberto Voci
el 22 de En. de 2020
Categorías
Más información sobre Text Files en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!