Why READTABLE skips the first line ?

조회 수: 18 (최근 30일)
Jean-Marie Sainthillier
Jean-Marie Sainthillier 2025년 4월 29일
댓글: Jean-Marie Sainthillier 2025년 4월 29일
I have this Excel file (it's just a simplified detail) with different variables (only numeric or text, with nan values). Each line correspond to a patient.
If I use readtable, MATLAB skips the first line without warning.
I can use readcell instead but i want to understand why MATLAB makes this choice.
If I move the first line elsewhere, everything is OK.
Any explanation ?
Thank you in advance.
SAINTHILLIER Jean Marie
data = readtable('Test_pb.xlsx')
data = 2x4 table
A B C D _____________ _ _______ _ {'SKIN-0002'} 1 {'yes'} 3 {'SKIN-0003'} 3 {'yes'} 4

답변 (2개)

Mohammad Sami
Mohammad Sami 2025년 4월 29일
You can modify the behaviour of read table function by optional arguments. What you want to do it specify the Number of header lines to skip at the beginning of the file, specified as NumHeaderLines and either 0 or a positive integer. If unspecified, readtable automatically detects the number of lines to skip.
  댓글 수: 1
Jean-Marie Sainthillier
Jean-Marie Sainthillier 2025년 4월 29일
I tried that first, but it doesn't work

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


Stephen23
Stephen23 2025년 4월 29일
편집: Stephen23 2025년 4월 29일
"Why READTABLE skips the first line ?"
Possibly because all of the text are shared strings, which perhaps confuses the READTABLE heuristics.
In any case, you do not need to use READCELL:
data = readtable('Test_pb.xlsx', 'DataRange','A2', 'VariableNamesRange','A1')
data = 3x4 table
A B C D _____________ ___ _______ ___ {'SKIN-0001'} NaN {'no' } NaN {'SKIN-0002'} 1 {'yes'} 3 {'SKIN-0003'} 3 {'yes'} 4

카테고리

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

태그

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by