reporting: add writeCSV option for tables. closes #693
parent
5b7b8da7fa
commit
f3c807f577
|
@ -11503,7 +11503,7 @@ reports. Default: @code{`black'}
|
|||
@end table
|
||||
@end defmethod
|
||||
|
||||
@defmethod Report addTable data, showHlines, precision, range, seriesToUse, tableDirName, tableName, title, titleFormat, vlineAfter, vlineAfterEndOfPeriod, showVlines
|
||||
@defmethod Report addTable data, showHlines, precision, range, seriesToUse, tableDirName, tableName, title, titleFormat, vlineAfter, vlineAfterEndOfPeriod, showVlines, writeCSV
|
||||
Adds a @code{Table} to a @code{Section}.
|
||||
@optionshead
|
||||
@table @code
|
||||
|
@ -11523,10 +11523,12 @@ The date range of the data to be displayed. Default: @code{all}
|
|||
@item seriesToUse, @code{CELL_ARRAY_STRINGS}
|
||||
@xref{seriesToUse}.
|
||||
|
||||
@anchor{tableDirName}
|
||||
@item tableDirName, @code{STRING}
|
||||
The name of the folder in which to store this table. Default:
|
||||
@code{tmpRepDir}
|
||||
|
||||
@anchor{tableName}
|
||||
@item tableName, @code{STRING}
|
||||
The name to use when saving this table. Default: something of the
|
||||
form @code{table_pg1_sec2_row1_col3.tex}
|
||||
|
@ -11547,6 +11549,13 @@ every year, after the fourth quarter, etc.). Default: @code{false}
|
|||
|
||||
@item showVlines, @code{BOOLEAN}
|
||||
Whether or not to show vertical lines separating the columns. Default: @code{false}
|
||||
|
||||
@item writeCSV, @code{BOOLEAN}
|
||||
Whether or not to write a CSV file containing the data displayed in the
|
||||
table. The file will be saved in the directory specified by @ref{tableDirName}
|
||||
with the same base name as specified by @ref{tableName} with the ending
|
||||
@code{.csv}. Default: @code{false}
|
||||
|
||||
@end table
|
||||
@end defmethod
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ o.data = '';
|
|||
o.seriesToUse = '';
|
||||
o.range = {};
|
||||
o.precision = 1;
|
||||
o.writeCSV = false;
|
||||
|
||||
if nargin == 1
|
||||
assert(isa(varargin{1}, 'report_table'),['With one arg to Report_Table constructor, ' ...
|
||||
|
@ -115,6 +116,7 @@ assert(iscellstr(o.titleFormat), ...
|
|||
'@report_table.report_table: titleFormat must be a cell array of string(s)');
|
||||
assert(ischar(o.tableName), '@report_table.report_table: tableName must be a string');
|
||||
assert(ischar(o.tableDirName), '@report_table.report_table: tableDirName must be a string');
|
||||
assert(islogical(o.writeCSV), '@report_table.report_table: writeCSV must be either true or false');
|
||||
|
||||
% using o.seriesToUse, create series objects and put them in o.series
|
||||
if ~isempty(o.data)
|
||||
|
|
|
@ -171,13 +171,26 @@ fprintf(fid, '\\hline%%\n');
|
|||
fprintf(fid, '%%\n');
|
||||
|
||||
% Write Report_Table Data
|
||||
if o.writeCSV
|
||||
csvseries = dseries();
|
||||
end
|
||||
for i=1:ne
|
||||
o.series{i}.writeSeriesForTable(fid, o.range, o.precision, ncols);
|
||||
if o.writeCSV
|
||||
if isempty(o.series{i}.tableSubSectionHeader)
|
||||
csvseries = [csvseries ...
|
||||
o.series{i}.data(dates).set_names([...
|
||||
num2str(i) '_' ...
|
||||
o.series{i}.data.name{:}])];
|
||||
end
|
||||
end
|
||||
if o.showHlines
|
||||
fprintf(fid, '\\hline\n');
|
||||
end
|
||||
end
|
||||
|
||||
if o.writeCSV
|
||||
csvseries.save(strrep(o.tableName, '.tex', ''), 'csv');
|
||||
end
|
||||
fprintf(fid, '\\bottomrule\n');
|
||||
fprintf(fid, '\\end{tabular}\\setlength{\\parindent}{0pt}\n \\par \\medskip\n\n');
|
||||
fprintf(fid, '%% End Report_Table Object\n');
|
||||
|
|
|
@ -43,7 +43,8 @@ notForOtherThree = {'BLT_', 'UNR_', 'UNR_BAR_', 'UNR_GAP_'};
|
|||
|
||||
rep = rep.addTable('title', countryName, ...
|
||||
'range', {trange, dates('2012a'):dates('2014a')}, ...
|
||||
'vlineAfter', {vline_after dates('2014q4')});
|
||||
'vlineAfter', {vline_after dates('2014q4')}, ...
|
||||
'writeCSV', true);
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue