Write timetable to file
writetimetable(
writes the timetable
TT
)TT
to a comma-delimited text file. The file name is the workspace
variable name of the timetable, appended with the extension .txt
. If
writetimetable
cannot construct the file name from the input timetable
name, then it writes to the file timetable.txt
.
Each column of each variable in TT
becomes a column in the output
file. The variable names of TT
become column headings in the first line
of the file. The writetimetable
function overwrites any existing
file.
writetimetable(
writes to a file with the name and extension specified by
TT
,filename
)filename
.
writetimetable
determines the file format based on the specified
extension. The extension must be one of the following:
.txt
, .dat
, or .csv
for
delimited text files
.xls
, .xlsm
, or .xlsx
for
Excel® spreadsheet files
.xlsb
for Excel spreadsheet files supported on systems with Excel for Windows®
writetimetable(___,
uses additional options specified by one or more Name,Value
)Name,Value
pair
arguments and can include any of the input arguments in previous syntaxes.
For example, you can specify whether to write the variable names as column headings in the output file.
To set the 'PreserveFormat'
name-value pair to
true
, you must set the 'UseExcel'
name-value pair
to true
.
There are some instances where the writetimetable
function creates a
file that does not represent the input data exactly. You will notice this when you use the
readtimetable
function to read that file. The resulting data might not have the exact same format or
contents as the original data. If you need to save your timetable and retrieve it at a later
time to exactly match the original timetable, with the same data and organization, then save
it as a MAT-file. writetimetable
writes an inexact table in the following instances:
writetimetable
writes out numeric data using long
g
format, and categorical or character data as unquoted text.
writetimetable
writes out variables that have more than two
dimensions as two dimensional variables, with the trailing dimensions collapsed.
For cell-valued variables, writetimetable
writes out the
variables differently based on the data type of the content in the cells.
If the content of the cell is of the data type numeric, text, logical,
categorical, datetime, or duration, then the writetimetable
function writes out the contents of each cell as a single row, in multiple,
delimiter-separated fields.
Otherwise, the writetimetable
function writes out a
single empty field.