How to fix excel file reading issue in MATLAB

조회 수: 2 (최근 30일)
Michael Fedorovsky
Michael Fedorovsky 2019년 7월 2일
댓글: dpb 2019년 7월 2일
I have a MATLAB script that takes a bunch of similarly formatted excel files and amalgamates the data in those files into one excel sheet.
ds = spreadsheetDatastore(pwd, 'Range', 'A2:CH3', 'ReadVariableNames', true)
ds.readall
T = ds.readall
writetable(T, 'UPDRS_master.xlsx')
It usually works fine but it seems that whenever a column starts with a number - and then a letter/string appears later on, it doesn't read that and a blank appears.
Does anyone know how to fix this?
  댓글 수: 1
dpb
dpb 2019년 7월 2일
Use detectimportoptions to create an import object and then use readtable with said object. You'll want to identify specifically by variable which is which -- the alternate routines set the data type based on the first data they find -- if it's numeric then the column is interpreted as numeric so if it really is mixed you'll need to define it as cellstr.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by