reading data from a file



If your file only has numbers and you want to read them as numbers
and they are acceptable to lisp ---  of the form 1.2  3  4.0d0
you should be able to use the lisp read function, e.g.
in the program below, do  tmp:?read(s)

and then you don't have to parse strings into numbers.

There is also a lisp function read-from-string that you might use.

My success in the earlier example was on wxmaxima, whatever lisp that is 
built on.

RJF



van Nek wrote:

> Am 16 Nov 2006 um 12:39 hat Fabrizio Caruso geschrieben:
>
>
>> but I can't find a way to read from a file.
>>
>>   Fabrizio
>
> Hi Fabrizio,
>
> in the package stringproc you find functions for input and output ...
>
> (%i1) load("stringproc")$
> (%i2) s: openr("D:/test.txt");
> (%o2)                             #<input stream D:/test.txt>
> (%i3) while stringp( tmp:readline(s) ) do print(tmp)$
> Hello,
> world!
> (%i4) close(s)$
>
> ... and for parsing and manipulating strings. One exception: These 
> functions cannot work with bigfloats. In case of bigfloats you should 
> consider function parse_string, which can be loaded by 
> load("eval_string").
>
> HTH
> Volker
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima
>  
>