reporting: add writeCSV option for tables. closes #693

remove-priordens
Houtan Bastani 2014-07-29 15:20:43 +02:00
parent 54adbb1e69
commit 2cbe1c34d9
2 changed files with 16 additions and 1 deletions

View File

@ -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)

View File

@ -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');