write
R2026bWrite distributed data to an output location
Description
write(
writes the values in the distributed array location,D)D to files
in the folder location. The data is stored in an
efficient binary format suitable for reading back using
datastore(location). If not distributed along
the first dimension, MATLAB® redistributes the data before writing, so that the
resulting files can be reread using
datastore.
write(
uses the file extension from filepattern,D)filepattern to determine
the output format. filepattern must include a folder
to write the files into followed by a file name that includes a wildcard
*. The wildcard represents incremental numbers
for generating unique file names, for example
write('folder/myfile_*.csv',D).
write(___,
specifies additional options with one or more name-value arguments using
any of the previous syntaxes. For example, you can specify the file type
with Name=Value)'FileType' and a valid file type
('mat', 'seq',
'parquet', 'text', or
'spreadsheet'), or you can specify a custom
write function to process the data with 'WriteFcn'
and a function handle.
Examples
Input Arguments
Name-Value Arguments
Limitations
In some cases,
write(location,D,"FileType",type)creates files that do not represent the original arrayDexactly. If you usedatastore(location)to read the checkpoint files, then the result might not have the same format or contents as the original distributed table.For the
"text"and"spreadsheet"file types,writeuses these rules:writeoutputs numeric variables usinglongGformat, and categorical, character, or string variables as unquoted text.For non-text variables that have more than one column,
writeoutputs multiple delimiter-separated fields on each line, and constructs suitable column headings for the first line of the file.writeoutputs variables with more than two dimensions as two-dimensional variables, with trailing dimensions collapsed.For cell-valued variables,
writeoutputs the contents of each cell as a single row, in multiple delimiter-separated fields, when the contents are numeric, logical, character, or categorical, and outputs a single empty field otherwise.
Do not use the
"text"or"spreadsheet"file types if you need to write an exact checkpoint of the distributed array.
Tips
Use the
writefunction to create checkpoints or snapshots of your data as you work. This practice allows you to reconstruct distributed arrays directly from files on disk rather than re-executing all of the commands that produced the distributed array.
Extended Capabilities
Version History
Introduced in R2017a