Use Import's automatic table detection programatically
조회 수: 2 (최근 30일)
이전 댓글 표시
When opening a *.csv with header in the "Import" window, the data table is automatically selected. Is there a way this can be done programatically? The methods described elsewhere (importdata, textread, csvread etc) are less generic and require knowledge of either the number of headerlines or header/table contents.
댓글 수: 1
Walter Roberson
2016년 9월 19일
Could you post an example of the first few lines of a couple of representative files you need to handle?
채택된 답변
Jeremy Hughes
2016년 9월 19일
It sounds like the R2016b function, http://www.mathworks.com/help/matlab/ref/detectimportoptions.html
댓글 수: 0
추가 답변 (2개)
Sean de Wolski
2016년 9월 19일
Have you tried readtable?
댓글 수: 2
Sean de Wolski
2016년 9월 19일
Also, give http://www.mathworks.com/help/matlab/ref/delimitedtextimportoptions-object.html in R2016b.
Star Strider
2016년 9월 19일
I don’t know what you included with ‘etc.’ in the file import functions you’ve used. Have you tried xlsread? It might be able to read your .csv file and do everything you want.
댓글 수: 2
Star Strider
2016년 9월 19일
You can get three outputs from xlsread, the first being the numeric values, the second all strings (column headers, dates, string variables), and the third everything in the file as a cell array. See Request Numeric, Text, and Raw Data in the xlsread documentation for details.
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!