<< writematrix | Spreadsheet |
writetable(T) |
writetable(T, filename) |
writetable(..., Name, Value) |
A table to be written to a file.
A string specifying the destination filename.
writetable(T) writes the table T to a comma-delimited text file.
The file name is derived from the table's workspace variable name, with the .txt
extension appended.
If the file name cannot be derived from the table name, the default file name table.txt
is used.
Output formats supported:
To specify the file name explicitly, use writetable(T, filename). The file format is determined by the file extension:
Additional options: Use writetable(..., Name, Value) for customization:
false
).'text'
or 'xml'
).true
).'overwrite'
or 'append'
).','
, '\t'
, etc.).'minimal'
, 'all'
, or 'none'
).'Attribute'
).'row'
).'table'
).Examples demonstrating various usages of
T = table([1; 2; 3], {'A'; 'B'; 'C'}, [10.5; 20.7; 30.2], 'VariableNames', {'ID', 'Name', 'Value'});
T.Value_Attribute = {'High'; 'Medium'; 'Low'};
% Basic usage - write to text file
writetable(T)
% Write to specific CSV file with custom delimiter
writetable(T, 'data.csv', 'Delimiter', ';')
% Write to XML with custom node names
writetable(T, 'data.xml', 'RowNodeName', 'record', 'TableNodeName', 'dataset')
% Append to existing file with row names
writetable(T, 'data.txt', 'WriteMode', 'append', 'WriteRowNames', true)
Version | Description |
---|---|
1.10.0 | Initial version. |
Allan CORNET