help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: io format specifier question


From: marco restelli
Subject: Re: io format specifier question
Date: Tue, 1 Jul 2008 21:37:38 +0200

On Tue, Jul 1, 2008 at 9:17 PM, Carlo de Falco <address@hidden> wrote:
>
> On 01/lug/08, at 19:24, A. Kalten wrote:
>
>> On Tue, 1 Jul 2008 20:02:36 +0200
>> "marco restelli" <address@hidden> wrote:
>>
>>>  I need to read an ASCII file containing floating point numbers as
>>>
>>> 0.112977-141
>>>
>>> which stands for 0.112977E-141 (i.e., the E is omitted). The point is,
>>> fscanf(fp,'%e') treats this as two numbers
>>>
>>
>> If you're on a unix system, just do:
>>
>> sed s/-/e-/ file > file-new
>>
>> This will convert all "0.112977-141" to "0.112977e-141"
>>
>> AK
>
> I am afraid that would mess up with negative numbers...
> Try:
>
> sed 's/\([0-9]*.[0-9]*\)\([-+]\)/\1e\2/' filename > newfilename
>
> this asumes you have one number per row...
> anyway, if it is easy to read this format in fortran, you can easily
> wrap a small fortran program in a DLD function to call it from octave.
>

Thank you AK, Carlo
   yes, your solution is an option.

Still I wonder whether there is a format descriptor in octave which
can handle this without preprocessing. The reason why I am insisting
is that all the home made preprocessing 1) tends to make the data
processing cumbersome when many files/people/systems are involved and
2) is likely to produce wrong results in various corner cases, which
might be standard in some sense (in my case, according to the FORTRAN
standard), but which I fail to take into account.

Anyway, thank you for the suggestion,

Marco




> c.
>
> P.S. Ciao Marco :)
>
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]