<< readtable Spreadsheet writematrix >>

writecell


Write a cell to a file.


Syntax


writecell(C)
writecell(C, filename)
writecell(..., Name, Value)

Input argument


C

an cell array.

filename

a string: filename destination.

Name, Value

Name-Value Arguments

Description


writecell writes an cell array to an CSV format file.

writecell does not support sparse matrices.

writecell outputs numeric data in the long G format.

Available Name-Value Arguments

Name-value pairs must follow all other arguments.

The order of name-value pairs doesn't matter

Delimiter and QuoteStrings options only apply to delimited text files.

FileType: Specifies the type of output file

Syntax: 'FileType','text'

Supports delimited text files (.txt, .dat, .csv)

WriteMode: Controls how data is written to the file

Syntax: 'WriteMode', mode

Options:

'overwrite' (default) - Creates new file or replaces existing content

'append' - Adds data to end of existing file

If the target file doesn't exist, a new file will be created regardless of mode.

Delimiter: Defines the character used to separate fields

Syntax: 'Delimiter', delimiter

Available Delimiters: Only applicable for delimited text files.

Specifier Alternative Description
',' 'comma' Comma (default)
' ' 'space' Space character
'\t' 'tab' Tab character
';' 'semi' Semicolon
'|' 'bar' Vertical bar

QuoteStrings: Controls text quoting behavior (Only applicable for delimited text files).

'QuoteStrings', option

with options

'minimal' (default) Quotes only text containing delimiters, line endings, or quotes.

'all' Quotes all text variables.

'none' Uses no quotes.

Example


C = {'ID', 'Product', 'Price'; 1, 'Laptop', 799.99; 2, 'Phone', 699.49; 3, 'Tablet', 499.00};
filename = [tempdir(), 'writecell_example.csv'];
writecell(C, filename);
R = fileread(filename)

See also


readcell, csvwrite, dlmread, fileread.

History


Version Description
1.10.0 initial version

Author


Allan CORNET

<< readtable Spreadsheet writematrix >>