Main Content

Text Files

Delimited and formatted text files

Read and write numeric and non-numeric data in delimited and formatted text files, including .csv and .txt files.


Import ToolImport data from file

Live Editor Tasks

Import DataImport data from a file in the Live Editor (Seit R2023a)


alle erweitern

Basic Import and Export

readtableCreate table from file
writetableWrite table to file
readtimetableCreate timetable from file (Seit R2019a)
writetimetableWrite timetable to file (Seit R2019a)

Define Import Rules

detectImportOptionsCreate import options based on file content
delimitedTextImportOptionsImport options object for delimited text
fixedWidthImportOptionsImport options object for fixed-width text files
xmlImportOptionsImport options object for XML files (Seit R2021a)
htmlImportOptionsImport options object for HTML files (Seit R2021b)
wordDocumentImportOptionsImport options object for Microsoft Word document files (Seit R2021b)
getvaroptsGet variable import options
setvaroptsSet variable import options
setvartypeSet variable data types
previewPreview eight rows from file using import options
readmatrixRead matrix from file (Seit R2019a)
writematrixWrite a matrix to a file (Seit R2019a)
readcellCreate cell array from file (Seit R2019a)
writecellWrite cell array to file (Seit R2019a)
readvarsRead variables from file (Seit R2019a)
textscanRead formatted data from text file or string
typeDisplay contents of file
filereadRead contents of file as text
readlinesRead lines of file as string array (Seit R2020b)
writelinesWrite text to file (Seit R2022a)


tabularTextDatastoreDatastore for tabular text files


Read Tabular Data from Text Files

Write Tabular Data to Text Files

  • Write Data to Text Files
    Export tabular data contained in tables, cell arrays, or numeric arrays from the MATLAB workspace to text files.