Main Content

Import Tool

Import data from file


The Import Tool lets you preview and import data from spreadsheet files, delimited text files, and fixed-width text files. You can interactively select the data to import and reuse the script or function that the tool generates to import other similar files.

Open the Import Tool

  • MATLAB® Toolstrip: On the Home tab, in the Variable section, click Import Data.

  • MATLAB command prompt: Enter uiimport(filename), where filename is a character vector specifying the name of a text or spreadsheet file.


expand all

Import ranges of data from a tab-delimited text file and replace nonnumeric values in the file.

Drag the cursor to select the cells to import. Press Ctrl to select noncontiguous ranges.

Modify the Variable Names Row field to indicate the row you want the Import Tool to use for the variable names.

By default, NaN replaces unimportable values in numeric cells. However, you can change this value to any other numeric value. Specify how to treat unimportable values on the Import tab, in the Unimportable Cells section.

Alternatively, exclude any row that contains an unimportable cell from being imported.

Click Import Selection . The new column vectors appear in your workspace.

Import dates and numbers from a text file into a table. Specify the decimal separator for numeric values in the file and a custom format for dates.

In the Imported Data section, select Table to import the file data into a table variable. In this example, the third column of data contains monetary amounts where the decimal separator is a comma. In the Delimiters section, select Delimiter Options. Then, under Decimal Separator, select , (comma).

The Import Tool appropriately converts the monetary values.

Specify that a column contains date or time data by changing the data type for the column to DATE/TIME. Click more date formats.... Scroll down the list to enter a custom date format.

Click Import Selection to import the table.

Related Examples

Programmatic Use

expand all

uiimport opens a dialog to interactively load data from a file or the clipboard. MATLAB displays a preview of the data in the file.

uiimport(filename) opens the file specified in filename using either Import Tool or Import Wizard depending on the file type. For spreadsheet and text files, uiimport opens the file using Import Tool. For all other file types, such as image, audio, or MAT-files, uiimport opens the file using Import Wizard.

uiimport('-file') presents the file selection dialog first.

uiimport('-pastespecial') presents the clipboard contents first.

S = uiimport(___) opens the file using Import Wizard and stores the resulting variables as fields in the struct S.

Version History

expand all

Behavior changed in R2020a