필터 지우기
필터 지우기

header row causes issues in readtable

조회 수: 225 (최근 30일)
Budding MATLAB Jockey
Budding MATLAB Jockey 2020년 5월 12일
답변: Walter Roberson 2020년 5월 13일
Hello I am stumped
I have a pile of files like the attached. They are tab delimited even though they are .csv files.
If I remove the header I can use readtable just fine but I can't figure out how to import the data using readTable without manually deleating the header from each file...
The header and data has the same number of columns.
Otherwise I can't figure out a reasonable way to import them.
To be honest, I don't care about even having the right variable names but I can't work around it.
  댓글 수: 3
Budding MATLAB Jockey
Budding MATLAB Jockey 2020년 5월 13일
So with that as false it would end up piling everyhing into 1 huge cell for some reason.
My friend tried my same code and same files and it worked. He has a newer matlab so I'll just ignore this for now. If a versino change solves it then I'll just get someone else to run it when the time comes
thanks though!
Star Strider
Star Strider 2020년 5월 13일

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 13일
T = readtable('testfile.csv', 'ReadVariableNames', false, 'HeaderLines', 1);
Or, R2019b or later,
T = readtable('testfile.csv', 'PreserveVariableNames', true);
Note that the code guesses 'MM/dd/uuuu HH:mm' format instead of 'dd/MM/uuuu HH:mm' . If there were enough input in a column that it could figure it out then it would not have to guess. You can force a particular interpretation by using detectImportOptions and using setvaroptions() of 'InputFormat' and then passing the options to readtable()

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by