|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
textreadThere seems to be a bug in textread (Octave 3.0.1 binary from
sourceforge, Windows XP) related to the 'headerlines' parameter. Assume the following in a file test.txt (without the start and end tags): --start 1stHeaderLine 1 1stDataLine 2 2ndDataLine --end This, according to the help text can be read by issuing: [a, b] = textread ('E:\test.txt', '%d %s', 'headerlines',2) a = 1 b = { [1,1] = 1stDataLine } Hence, the last line is is not read. Changing the file test.txt to --start 1stHeaderLine 1 1stDataLine 2 2ndDataLine --end , so by omitting the empty second header line, textread behaves as expected: [a, b] = textread ('E:\test.txt', '%d %s', 'headerlines',1) a = 1 2 b = { [1,1] = 1stDataLine [2,1] = 2ndDataLine } Cheers, Michael _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: textreadMichael Grossbach wrote:
> There seems to be a bug in textread (Octave 3.0.1 binary from > sourceforge, Windows XP) related to the 'headerlines' parameter. > Assume the following in a file test.txt (without the start and end tags): As this is currently an octave-forge function the bug should be sent to octave-dev@.... That being said it, textread probably should be a core function, so hey.. The issue is that textread ignores the blank lines in the header in the TextRead::lines method and then effective does it against when it subtracts the number of headerlines from nr_rows. Patch attached. D. Index: textread.cc =================================================================== --- textread.cc (revision 5037) +++ textread.cc (working copy) @@ -80,7 +80,7 @@ } long unsigned int - lines() + lines(int headerlines) { if (_lines == 0) { @@ -93,7 +93,7 @@ char buf[BUFFER_SIZE]; while (!tmpdata.eof()) { tmpdata.getline(buf, BUFFER_SIZE); - if (std::string(buf).length() != 0) { + if (_lines < headerlines || std::string(buf).length() != 0) { _lines++; } } @@ -252,8 +252,6 @@ return retval; } - - TextFile input(filename.c_str()); if (!input.is_valid()) { return retval; @@ -268,7 +266,7 @@ input.set_format(repeated_fmt); input.ignore_whitespace(); - long unsigned int nr_rows = input.lines(); + long unsigned int nr_rows = input.lines(headerlines); if (nr_rows == 0) { return octave_value (Matrix ()); _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: textreadOn 13-May-2008, David Bateman wrote:
| Michael Grossbach wrote: | > There seems to be a bug in textread (Octave 3.0.1 binary from | > sourceforge, Windows XP) related to the 'headerlines' parameter. | > Assume the following in a file test.txt (without the start and end tags): | | As this is currently an octave-forge function the bug should be sent to | octave-dev@.... That being said it, textread probably | should be a core function, so hey.. I'd consider it if somone would update it to match the Octave coding style and submit it as a patch. Thanks, jwe _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
| Free Forum Powered by Nabble | Forum Help |