From: <cde...@us...> - 2010-11-16 17:29:01
|
Revision: 7921 http://octave.svn.sourceforge.net/octave/?rev=7921&view=rev Author: cdemills Date: 2010-11-16 17:28:54 +0000 (Tue, 16 Nov 2010) Log Message: ----------- Refined the processing of EOL Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m trunk/octave-forge/extra/dataframe/inst/data_test.csv Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2010-11-16 07:57:25 UTC (rev 7920) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2010-11-16 17:28:54 UTC (rev 7921) @@ -160,13 +160,16 @@ unwind_protect_cleanup fclose(fid); end_unwind_protect - eol = '\r\n|\n|\x0b|\f|\r|\x85'; + eol = '(\r\n|\n|\r|\f|\x85)'; %# cut into lines -- include the EOL to have a one-to-one - %# matching between line numbers - lines = regexp(in, ['(^|' eol ')([^' eol ']+)'], 'match'); + %# matching between line numbers. Use a non-greedy match. + lines = regexp(in, ['.*?' eol], 'match'); + dummy = cellfun(@(x) regexp(x, eol), lines); %# remove the EOL character(s) - lines = cellfun(@(x) regexp(x, ['[^' eol ']+'], 'match'), lines); - + lines(1==dummy) = {""}; + %# use a positive lookahead -- eol is not part of the match + lines(dummy > 1) = cellfun(@(x) regexp(x, ['.*(?=' eol ')'], 'match'), \ + lines(dummy > 1)); %# a field either starts at a word boundary, either by + - . for %# a numeric data, either by ' for a string. Modified: trunk/octave-forge/extra/dataframe/inst/data_test.csv =================================================================== --- trunk/octave-forge/extra/dataframe/inst/data_test.csv 2010-11-16 07:57:25 UTC (rev 7920) +++ trunk/octave-forge/extra/dataframe/inst/data_test.csv 2010-11-16 17:28:54 UTC (rev 7921) @@ -1,9 +1,11 @@ DataName, VBIAS, Freq, IBIAS, C, G, OK DataValue, -6, 300000, 1.6272E-11, 7.02154E-13, 1.60436E-07, 'A' DataValue, -5.8, 300000, 1.599E-11, 6.96065E-13, 1.5728E-07, 'E' + DataValue, -5.6, 300000, 1.379E-11, 6.90475E-13, 1.54887E-07, '!' DataValue, -5.4, 300000, 1.442E-11, 6.85165E-13, 1.54777E-07, '?' DataValue, -5.2, 300000, 1.293E-11, 6.79655E-13, 1.51887E-07, 'C' + DataValue, -5, 300000, 1.261E-11, 6.74438E-13, 1.49309E-07, 'B' DataValue, -4.8, 300000, 1.439E-11, 6.70105E-13, 1.48758E-07, 'A' DataValue, -4.6, 300000, 1.089E-11, 6.64158E-13, 1.489E-07, '3' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |