From: <cde...@us...> - 2012-03-27 08:17:54
|
Revision: 10073 http://octave.svn.sourceforge.net/octave/?rev=10073&view=rev Author: cdemills Date: 2012-03-27 08:17:47 +0000 (Tue, 27 Mar 2012) Log Message: ----------- - when the separator is ' ', use the form of strsplit wich consider repetitions of the separator as one single value Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2012-03-26 19:46:13 UTC (rev 10072) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2012-03-27 08:17:47 UTC (rev 10073) @@ -210,9 +210,15 @@ %# content = cellfun(@(x) regexp(x, '(\b|[-+\.''])[^,]*(''|\b)', 'match'),\ %# lines, 'UniformOutput', false); %# extract fields - content = cellfun (@(x) strsplit (x, sep), lines, \ - 'UniformOutput', false); %# extract fields - indl = 1; indj = 1; %#disp('line 151 '); keyboard + + if (strfind (sep, ' ')) + content = cellfun (@(x) strsplit (x, sep, true), lines, \ + 'UniformOutput', false); %# extract fields + else + content = cellfun (@(x) strsplit (x, sep), lines, \ + 'UniformOutput', false); %# extract fields + endif + indl = 1; indj = 1; %# disp('line 151 '); keyboard if (~isempty (seeked)) while (indl <= length (lines)) dummy = content{indl}; @@ -239,7 +245,7 @@ endif if (size (dummy, 2) >= 2 && ... ~isempty (regexp (dummy{2}, trigger, 'match'))) - %#was (strcmp (dummy{1}, trigger)) + %# was (strcmp (dummy{1}, trigger)) break; endif endwhile @@ -260,9 +266,16 @@ indl = indl + 1; indj = indj + 1; continue; endif + %# try to convert to float - the_line = cellfun (@(x) sscanf (x, "%f", locales), dummy, \ - 'UniformOutput', false); + if (1) + the_line = cellfun (@(x) sscanf (x, "%f", locales), dummy, \ + 'UniformOutput', false); + else + the_line = sscanf (dummy, "%f", locales); + the_line = cellfun (@(x) x{1}, the_line, 'UniformOutput', false); + endif + for indk = (1:size (the_line, 2)) if (isempty (the_line{indk}) || any (size (the_line{indk}) > 1)) %#if indi > 1 && indk > 1, disp('line 117 '); keyboard; %#endif @@ -284,11 +297,12 @@ x(indj, indk) = regexp (dummy{indk}, '[^ ].*', 'match'); endif else - if (~isempty (regexp (dummy{indk}, '[/:]'))) + if (~isempty (regexp (dummy{indk}, '[/:-]'))) %# try to convert to a date [timeval, nfields] = strptime( dummy{indk}, [char(37) 'd/' char(37) 'm/' char(37) 'Y ' char(37) 'T']); if (nfields > 0) %# at least a few fields are OK + keyboard timestr = strftime ([char(37) 'H:' char(37) 'M:' char(37) 'S'], timeval); %# try to extract the usec field, if any @@ -302,6 +316,9 @@ endif x(indj, indk) = str2num (strftime ([char(37) 's'], timeval)) + ... timeval.usec * 1e-6; + else + %# store it as is + x(indj, indk) = the_line{indk}; endif else x(indj, indk) = the_line{indk}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |