Subject: read external file with comments into a matrix
From: Robert Dodier
Date: Wed, 4 Aug 2010 10:07:30 -0600
On 8/4/10, Sebastian Ehrhart <Sebastian_Ehrhart at gmx.de> wrote:
> I want to use Maxima for data analysis and want to read in an external file
> with comment lines in the first rows. The external file looks like:
>
> # p=1013 T=293
> # x y
> 80.00 0.88
> 100.00 0.89
> ... a lot of more rows
>
> read_matrix(file) fails because of the comments. The optimal solution I was
> looking for would be tell Maxima everything in file that starts with # is a
> comment.
> On the other side saving the header as string could be useful for later use.
Try this:
s : openr ("my.data");
header1 : readline (s);
header2 : readline (s);
xy_data : read_matrix (s);
which is supposed to burn off the first 2 lines so
what remains is readable by read_matrix.
HTH
Robert Dodier