From: <cde...@us...> - 2012-03-07 08:04:26
|
Revision: 9758 http://octave.svn.sourceforge.net/octave/?rev=9758&view=rev Author: cdemills Date: 2012-03-07 08:04:20 +0000 (Wed, 07 Mar 2012) Log Message: ----------- Deduce column names when there are only separated by spaces Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m 2012-03-06 16:08:10 UTC (rev 9757) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m 2012-03-07 08:04:20 UTC (rev 9758) @@ -165,8 +165,12 @@ && ~all (df._over{2}(indc))) warning ("Trying to overwrite colum names"); endif - - ctype = RHS(1, :); RHS = RHS(2:end, :); + + if (sum (~cellfun ('isempty', RHS(1, indc))) == ncol) + ctype = RHS(1, :); + endif + + RHS = RHS(2:end, :); if (~indr_was_set) nrow = nrow - 1; indr = 1:nrow; endif @@ -244,7 +248,7 @@ df = df_pad (df, 1, max (indr)-df._cnt(1), rname_width); endif endif - + if (iscell(RHS)) %# we must pad on a column-by-column basis %# verify that each cell contains a non-empty vector, and that sizes %# are compatible @@ -268,6 +272,28 @@ keyboard endif + %# try to detect and remove bottom garbage + eff_len = zeros(nrow, 1); + for indi = (indr) + eff_len(indi, 1) = sum (~cellfun ('isempty', RHS(indi, :))); + endfor + indi = nrow; + while (indi > 0) + if (1 == eff_len(indi)) + nrow = nrow - 1; + indr(end) = []; + RHS(end, :) = []; + indi = indi - 1; + if (~indr_was_set && isempty (df._name{1, 1})) + df._cnt(1) = nrow; + df._ridx(end) = []; + endif + else + break; + endif + endwhile + clear eff_len; + %# the real assignement if (1 == size (RHS, 1)) %# each cell contains one vector fillfunc = @(x) RHS{x}; @@ -275,8 +301,8 @@ else %# use cell2mat to pad on a column-by-column basis fillfunc = @(x) cell2mat (RHS(:, x)); endif - - indj = 1; + + indj = 1; for indi = (1:ncol) if (indc(indi) > df._cnt(2)) %# perform dynamic resizing one-by-one, to get type right @@ -492,7 +518,18 @@ try df._name{2}(indc, 1) = genvarname (cname); catch - disp('line 472 '); keyboard + %# there was a problem with genvarname. + dummy = sum (~cellfun ('isempty', cname)); + if (1 == dummy) + dummy = strsplit(cname{1}, ' ', true); + if (length (dummy) == ncol) + df._name{2}(indc, 1) = dummy; + else + disp('line 528 '); keyboard + endif + else + disp('line 531 '); keyboard + endif end_try_catch df._over{2}(1, indc) = false; endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cde...@us...> - 2012-03-13 21:57:35
|
Revision: 9870 http://octave.svn.sourceforge.net/octave/?rev=9870&view=rev Author: cdemills Date: 2012-03-13 21:57:28 +0000 (Tue, 13 Mar 2012) Log Message: ----------- Ensure cells with strings and number are all converted to number Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m 2012-03-13 21:50:39 UTC (rev 9869) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m 2012-03-13 21:57:28 UTC (rev 9870) @@ -320,7 +320,8 @@ if (size (RHS, 1) <= 1) switch df._type{indc(indi)} case {'char' } %# use a cell array to hold strings - dummy = RHS(:, indj); + dummy = cellfun (@num2str, RHS(:, indj), \ + 'UniformOutput', false); case {'double' } dummy = fillfunc (indj); otherwise @@ -333,7 +334,8 @@ dummy = []; switch (df._type{indc(indi)}) case {'char' } %# use a cell array to hold strings - dummy = RHS(:, indj); + dummy = cellfun (@num2str, RHS(:, indj), \ + 'UniformOutput', false); case {'double' } dummy(idxOK, :) = fillfunc (indj); dummy(~idxOK, :) = NA; otherwise @@ -379,7 +381,8 @@ try switch (df._type{indc(indi)}) case {'char' } %# use a cell array to hold strings - dummy(indr, 1) = RHS(:, indj); + dummy(indr, 1) = cellfun(@num2str, RHS(:, indj), \ + 'UniformOutput', false); case {'double' } dummy(indr, :) = fillfunc (indj); otherwise This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cde...@us...> - 2012-03-29 14:33:15
|
Revision: 10092 http://octave.svn.sourceforge.net/octave/?rev=10092&view=rev Author: cdemills Date: 2012-03-29 14:33:05 +0000 (Thu, 29 Mar 2012) Log Message: ----------- - A few stylistic changes Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m 2012-03-29 07:52:00 UTC (rev 10091) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m 2012-03-29 14:33:05 UTC (rev 10092) @@ -391,7 +391,7 @@ catch dummy = \ sprintf ("Assignement failed for colum %d, of type %s and length %d,\nwith new content\n%s", \ - indj, df._type{indc(indi)}, length (indr), disp(RHS(:, indj))); + indj, df._type{indc(indi)}, length (indr), disp (RHS(:, indj))); error (dummy); end_try_catch endif @@ -426,14 +426,14 @@ [df, S] = df_cow(df, S, indc(indi)); if (strcmp (df._type(indc(indi)), RHS._type(indi))) try - df._data{indc(indi)} = feval(@subsasgn, df._data{indc(indi)}, S, \ - RHS._data{indi}(:, RHS._rep{indi})); + df._data{indc(indi)} = feval (@subsasgn, df._data{indc(indi)}, S, \ + RHS._data{indi}(:, RHS._rep{indi})); catch - disp(lasterr()); disp('line 516 ???'); keyboard + disp (lasterr ()); disp('line 516 ???'); keyboard end_try_catch else - df._data{indc(indi)} = feval(@subsasgn, df._data{indc(indi)}, S, \ - cast(RHS._data{indi}(:, RHS._rep{indi}),\ + df._data{indc(indi)} = feval (@subsasgn, df._data{indc(indi)}, S, \ + cast (RHS._data{indi}(:, RHS._rep{indi}),\ df._type(indc(indi)))); endif S = Sorig; @@ -480,8 +480,8 @@ df._data{indc(indi)} = fillfunc (df._data{indc(indi)}, S, indi); S = Sorig; catch - disp(lasterr) - disp('line 470 '); keyboard + disp (lasterr ()) + disp ('line 470 '); keyboard end_try_catch # catch # if ndims(df._data{indc(indi)}) > 2, @@ -557,10 +557,10 @@ if (length (dummy) == ncol) df._name{2}(indc, 1) = dummy; else - disp('line 528 '); keyboard + disp ('line 528 '); keyboard endif else - disp('line 531 '); keyboard + disp ('line 531 '); keyboard endif end_try_catch df._over{2}(1, indc) = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |