Bill Allombert on Wed, 04 Jul 2007 22:47:24 +0200


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

Re: how to read one line from a datafile at a time?


On Sun, Jul 01, 2007 at 09:19:51AM -0700, john n wrote:
> 
> How can I get PARI/GP to read one line from a datafile at a time, e.g. to
> assign to a specified variable?
> 
> I use
> 
> read(file)
> 
> and it simply prints out the last line in the file.
> 
> I need to be able to read the first line, assign it to e.g. a(1), then read
> the second line and assign it to a(2) and so on.

Hello,
You can use
a=readvec(file);
then 
a[1] is the value of the first line, a[2] the value of the second line, etc.

Cheers,
Bill.