183183
184184 methods (Access = public)
185185 function this = dbtable (varargin )
186-
186+ ## -*- texinfo -*-
187+ ## @deftypefn {} {@var{table } =} dbtable.dbtable ()
188+ ## @deftypefnx {} {@var{table } =} dbtable (@dots{} @var{propertyname}, @var{propertyvalue})
189+ ## Create a table of data
190+ ## @end deftypefn
191+
187192 # work out where properties start
188193 prop_idx = - 1 ;
189194 for idx = 1 : length(varargin )
@@ -435,6 +440,11 @@ function disp (this)
435440 endfunction
436441
437442 function summary (this)
443+ ## -*- texinfo -*-
444+ ## @deftypefn {} {} dbtable.summary ()
445+ ## Display summary of the table
446+ ## @end deftypefn
447+
438448 printf ("Properties: \n");
439449 printf (" %s: %s\ n", "Description", this.Properties.Description);
440450 printf ("Variables: \n");
@@ -450,8 +460,9 @@ function summary (this)
450460 endfor
451461 endfunction
452462
453- # rows , columns just calls size
454463 function varargout = size(this, dimn= 1 )
464+ # get size of table
465+
455466 sz0 = 0 ;
456467 sz1 = length(this._data);
457468 if sz1 > 0
@@ -477,22 +488,31 @@ function summary (this)
477488 endfunction
478489
479490 function s = length(this)
491+ # get length (number of rows) of table
480492 s = size(this, 1 );
481493 endfunction
482494
483495 function e = isempty(this)
496+ # check if table has data
484497 e = (length(this) == 0 );
485498 endfunction
486499
487500 function y = istable(this)
501+ # return true if we are a table
488502 y = true ;
489503 endfunction
490504
491505 function y = ismatrix(this)
506+ # return true is we are a matrix
492507 y = true ;
493508 endfunction
494509
495510 function st = table2struct(this)
511+ ## -*- texinfo -*-
512+ ## @deftypefn {} {@var{st } =} dbtable.table2struct ()
513+ ## Convert this table into a struct using the variable names as fields.
514+ ## @end deftypefn
515+
496516 names = this.Properties.VariableNames;
497517 st = {};
498518 for idx = 1 : numel(names)
@@ -501,6 +521,11 @@ function summary (this)
501521 endfunction
502522
503523 function writetable (this, filename)
524+ ## -*- texinfo -*-
525+ ## @deftypefn {} {} dbtable.writetable (@var{filename})
526+ ## Save table to a file (Currently only csv is supported)
527+ ## @end deftypefn
528+
504529 [~ , ~ , ext ] = fileparts (filename);
505530 if isempty (ext)
506531 ext = " .csv"
@@ -514,8 +539,9 @@ function writetable (this, filename)
514539 endswitch
515540 endfunction
516541
517- # head tail - create sub tables
518542 function tdata = head(this, rows= 8 )
543+ # get the first X rows of the table
544+
519545 if nargin > 1 && !isnumeric (rows)
520546 error ("Expected rows to be a number");
521547 endif
@@ -529,6 +555,8 @@ function writetable (this, filename)
529555 endfunction
530556
531557 function tdata = tail(this, rows= 8 )
558+ # get the last X rows ofthe table
559+
532560 if nargin > 1 && !isnumeric (rows)
533561 error ("Expected rows to be a number");
534562 endif
@@ -543,15 +571,6 @@ function writetable (this, filename)
543571 tdata = dbtable(data{: }, ' VariableNames' , names);
544572 endfunction
545573 endmethods
546-
547- %{
548- # octave ignores hiddent currently
549- methods (Hidden = true)
550- function tdata = _RawData(this)
551- tdata = this._data;
552- endfunction
553- endmethods
554- %}
555574endclassdef
556575
557576% !test
0 commit comments