Read and write numeric and nonnumeric data in delimited and
formatted text files, including
Import text file data interactively using the Import Tool. Import or export text data programmatically
using the functions on this page. To compare primary import options
for text files, see Ways to Import Text Files.
|Create table from file|
|Create import options based on file content|
|Write table to file|
|Read formatted data from text file or string|
|Read ASCII-delimited file of numeric data into matrix|
|Write matrix to ASCII-delimited file|
|Read comma-separated value (CSV) file|
|Write comma-separated value file|
|Display contents of file|
This example shows how to import data from a text file with column headers and numeric data using the Import Tool.
This example shows how to import comma-separated numeric data from a text file, using the
This example shows how to use the
readtable function to import mixed data from a text file into a table.
This example shows how to read small blocks
of data from an arbitrarily large delimited text file using the
textscan function and avoid memory errors.
This example shows how to import data from
a nonrectangular file using the
Formatted dates and times (such as
are not numeric fields.
To export a numeric array as a delimited ASCII data file, you
can use either the
save function, specifying the
To import or export multiple files, create a control loop to process one file at a time.
For customized data import and additional control over the import process, define and use the import options.
You can import text files into MATLAB® both interactively and programmatically.