ods2timetable
datatypes: tt = ods2timetable (filename)
datatypes: tt = ods2timetable (filename, Name, Value)
Read an OpenDocument spreadsheet file into a timetable.
tt = ods2timetable (filename) reads a sheet of the
OpenDocument spreadsheet named by filename into a timetable.
filename may be a character vector, a cellstr, or a string scalar.
A sheet written by timetable2ods carries the package’s own metadata,
which names and types every variable and tags the leading column of row
times with their type, their TimeZone where they have one, and their
Format. Such a sheet comes back as the timetable it was written
from: the row times keep their type, zone and format exactly, and the row
dimension keeps its name.
Any other sheet is read as ods2table reads it, and its first
datetime or duration variable becomes the row times, the row
dimension taking that variable’s name. A sheet with no such variable cannot
be read as a timetable.
Every Name-Value option of ods2table is accepted and
behaves as it does there, with two exceptions. 'ReadRowNames' and
'RowNamesColumn' are refused: a timetable labels its rows by time
and by nothing else, so a sheet whose rows are named is read with
ods2table.
TimeStep and SampleRate are not stored in the file and are
worked out again from the row times, so a regular timetable comes back
regular.
An event table is held on a sheet of its own, named by a
## Events crossref: line in the hidden metadata sheet, and is
attached to the timetable that names it. With no 'Sheet' given the
first data sheet is read less the sheets that hold somebody’s
events, so a file holding one timetable and its events reads with no
argument at all. A sheet asked for by name or by index is read whichever it
is, the index running over every data sheet so that one number means one
sheet here and in ods2table alike; an event sheet asked for by name
comes back as the eventtable it is.
A reference is refused when it names a sheet the file does not have, when the sheet it names holds no row times, when those row times are of a different type than the referring timetable’s, or when the sheet it names carries a reference of its own, an event table not being something that can carry an event table. All four are reachable only in a file edited by hand.
See also: timetable.timetable2ods, ods2table, ods2struct, csv2timetable, timetable
Source Code: ods2timetable
A timetable written by timetable2ods comes back whole: the row times keep their type, their time zone and their display format, the row dimension keeps its name, and the spreadsheet shows the times as times because they are written as native date cells.
t = datetime (2024, 3, 9, 22, 0, 0, 'TimeZone', 'America/New_York') ...
+ hours ((0:3)');
TT = timetable (t, (1:4)', 'VariableNames', {'reading'});
TT.Properties.DimensionNames{1} = 'Stamp';
fname = [tempname(), '.ods'];
timetable2ods (TT, fname);
ods2timetable (fname)
ans =
4x1 timetable
Stamp reading
____________________ _______
09-Mar-2024 22:00:00 1
09-Mar-2024 23:00:00 2
10-Mar-2024 00:00:00 3
10-Mar-2024 01:00:00 4
delete (fname);