problem in reading text files
Ben Abbott
bpabbott at mac.com
Fri Sep 5 10:51:50 CDT 2008
On Friday, September 05, 2008, at 09:08AM, "Dmitri A. Sergatskov" <dasergatskov at gmail.com> wrote:
>Ben, -- I assume you forgot to CC it to the octave-bug
>
>On Fri, Sep 5, 2008 at 5:48 AM, Ben Abbott <bpabbott at mac.com> wrote:
>>
>> On Sep 4, 2008, at 11:27 PM, Yaping Zhou wrote:
>>
>>> Dmitri Ben:
>>>
>>> Thanks.
>>>
>>> Dmitri said he was using 3.0.2. What version are you Ben using?
>>>
>>> I was using 3.0.1 in Windows and here are what I got. OK.txt was loaded
>>> successfully while NotOK.txt wasn't OK.
>>>
>>> <11629977.gif>
>>>
>>>
>> I'm running 3.0.1.
>>
>> However, it won't make any difference. The problem is with the EOL
>> character.
>>
>> Can someone who knows tell us if the Octave expects the same EOL character
>> for files on all OS's, if Octave is intended to be agnostic to dos/mac/unix
>> EOL characters, or if different EOL characters are expected depending upon
>> OS?
>
>I think it is a bug.
>
>It works with any termination if the file in "-ascii" format (no header).
>But in ASCII format one cannot save complex numbers. I assume this is a feature,
>though it is not documented, it just prints a warning:
>
>octave:1> z = ones(3,3) + 2i * ones(3,3)
>z =
>
> 1 + 2i 1 + 2i 1 + 2i
> 1 + 2i 1 + 2i 1 + 2i
> 1 + 2i 1 + 2i 1 + 2i
>
>octave:2> save -ascii "z.dat" z
>warning: save: omitting imaginary part for ASCII file
>
The omission of the imaginary part is consistent with Matlab.
Regarding the ascii-octave variant, can anyone verify if Octave, running on different operating systems, saves these files with different EOL character's?
What I'm wondering ... might these files have been edited with a text editor that modified their EOL characters rendering their format incompatible with what is supported by Octave?
If so, it may be relatively simple to add the support for various line endings by examining ls-mat-ascii.cc. Is there any reason why we wouldn't want to do that?
Ben
p.s. I'm browsing the sources, but my c/c++ is poor enough that I'm not to be trusted with such ;-)
More information about the Bug-octave
mailing list