Import Explorer to help you with importing table data
When importing data as a table, you can use detectImportOptions to customize how you bring in your data. You can choose to import specific columns, specify the data type of each column, specify how to treat missing values, and many more.
Import Explorer
Jan's entry is a visual tool to help with this customization. It also lets you save the output for detectImportOptions so that you can programmatically reproduce the operation. See this in action.
Programmatic Approach
As a comparision, here's how you would do it programmatically from scratch.
opts = detectImportOptions("airlinesmall.csv")
opts.VariableTypes([9 17 18]) = {'categorical'};
opts.SelectedVariableNames = opts.VariableNames([1 2 3 5 7 9 10 15 16 17 18]);
data = readtable("airlinesmall.csv",opts);
Import Tool
Of course, there is the Import Tool that comes with MATLAB. You can do many of these customizations from the tool.
Jan's Import Explorer gives you a bit more options, since detectImportOptions provides those. In addition, Jan's tool works with multiple files, in which case it uses the datastore function under the hood.
A small request I have is for this to work with other file types, such as Excel files. Currently, this tool only works with CSV and TXT files.
评论
要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。