CSV Variable Names truncated on 2 rows how to append
이전 댓글 표시
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
Umberto Voci
2020년 1월 13일
편집: Umberto Voci
2020년 1월 13일
채택된 답변
추가 답변 (1개)
Jyotsna Talluri
2020년 1월 22일
0 개 추천
You can read the CSV files using readtable function and then you can modify the data as required
Refer to the below link
댓글 수: 1
Umberto Voci
2020년 1월 22일
편집: Umberto Voci
2020년 1월 22일
카테고리
도움말 센터 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!