[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #37023] strread with leading white space in ne
From: |
Xuejin Wang |
Subject: |
[Octave-bug-tracker] [bug #37023] strread with leading white space in new lines |
Date: |
Fri, 03 Aug 2012 22:58:49 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1 |
URL:
<http://savannah.gnu.org/bugs/?37023>
Summary: strread with leading white space in new lines
Project: GNU Octave
Submitted by: fclxc10
Submitted on: Fri 03 Aug 2012 10:58:48 PM GMT
Category: None
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 3.6.1
Operating System: Microsoft Windows
_______________________________________________________
Details:
When using textscan to read some data from a text file, if a new line starts
with a space and the previous line ends with a space, the first data in that
line becomes "NaN".
For example, if the text file is as follows:
0 1
2 3
It has two lines, each line starts with a space. The following command is used
for reading the file:
data = textscan(fid,'%f %f')
The first line is always OK. If the first line has no space at its end, the
second line is also OK. However if the first line has a space at the end
(after the number "1" at the end of line 1), the first column becomes [0 NaN
3]', and the second column is [1 2]'.
I traced the problem to the function strread, line 373-380:
## Check for single delimiter followed/preceded by whitespace
## FIXME: Double strrep on str is enormously expensive of CPU time.
## Can this be eliminated
if (! isempty (delimiter_str))
dlmstr = setdiff (delimiter_str, " ");
rxp_dlmwsp = sprintf ("( [%s]|[%s] )", dlmstr, dlmstr);
str = regexprep (str, rxp_dlmwsp, delimiter_str(1));
endif
My workaround is to run line 381-387 before the above lines. Maybe you'll have
a better solution for it.
Thanks,
Xuejin
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?37023>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #37023] strread with leading white space in new lines,
Xuejin Wang <=