How can I use 'textscan' to read data from Sheet2 of an Excel file?

조회 수: 12 (최근 30일)
Tahir Ameen
Tahir Ameen 2019년 1월 6일
편집: per isakson 2019년 1월 7일
As said in question, want to know if textscan can be used to scan data from Sheet2 of an Excel file?
Thanks for any help.
  댓글 수: 8
Jan
Jan 2019년 1월 7일
@Tahir Ameen: CSV files do not have sheets. A CSV file is a text file and there is no way to define something like a sheet in it. Then neither textscan cannot have the power to select a sheet. Sheets are properties of binary XLS and XLSX files. There is no way to use a tool written to import text files of a certain format to import binary files on another format.
Summary: textscan imports text files only and text files do not have sheets. If you need to import sheets, use readtable or xlsread.
Now you reveal, that you are struggeling with dates. Of course this can be solved directly without the need of the time-consuming indirection over CSV files. Please post the current code and an example file. Then it is possible to suggest a solution.
per isakson
per isakson 2019년 1월 7일
편집: per isakson 2019년 1월 7일
Caveat: Personally I try to avoid Excel. What looks like datetime in Excel may be a character string or "datenum of Excel" presented as datetime. xlsread reads the first as a character string and the latter as a "strange number".

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

채택된 답변

per isakson
per isakson 2019년 1월 7일
Try
readtable( _______, 'DatetimeType', 'exceldatenum' );
See the documentation.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by