Use Import's automatic table detection programatically
显示 更早的评论
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?
采纳的回答
更多回答(2 个)
Sean de Wolski
2016-9-19
0 个投票
Have you tried readtable?
2 个评论
C Hinderink
2016-9-19
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
0 个投票
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 个评论
C Hinderink
2016-9-19
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!