Reading data from a file (or stdin)



several solutions come to mind:
(a) there may be a read() command in maxima.  if not
(b) the file could be opened in lisp and read, doing something like
     filedescriptor:?open("datafile");
     ... loop do...  x1:?read(filedescriptor), y1:?read(filedescriptor) 
.....
(c) change the file so that instead of

1.0 2.0 3.0
4.0 5.0 ...


you have

listofdata:
[1.0,2.0,3.0,
  4.0,5.0, ...]$


or perhaps
listoflistofdata:
[[1.0  .... ],
  [4.0, .... ]]$

Then load("datafile") should work.

RJF



Billinghurst, David (CRTS) wrote:
> I am trying to check results from Fortran code in maxima
> 
> What I want to do is read lines of data from a file (or stdin), calculate some results, and print a mesage if a comparison fails.
> 
> For example, I have files of data of the form
> 
> x1 y1 z1 f1
> x2 y2 z2 f2
>  ......
> xn yn zn fn
> 
> where the entries are floating point numbers.
> 
> I want to:
>  - read the data in a line at a time
>  - calculate f(xi,yi,zi)
>  - compare f(xi,yi,zi) with fi
>  - generate some output if the comparison fails.
> 
> 
> I have made some progress by transforming the file into straight line maxima code using awk, but was wondering if there was a more elegent solution.
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima