[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Equivalent to scanf()?
- From: "steve donovan" <steve.j.donovan@...>
- Date: Wed, 14 Nov 2007 10:27:09 +0200
On Nov 14, 2007 9:39 AM, Arturo Amaldi <firstname.lastname@example.org> wrote:
>I often have to deal with tables of
> numbers written in exponential or floating point notation, and the use
> of sscanf on a line iteration made it much easier to read in data. I
> know i could use the "*number" format but I'd rather read the file
> line by line and separate it afterwards.
Here's one way:
For example, here is a little program to sum all the numbers in a file:
for x in numbers() do
s = s + x
But the _verification_ issue is delicate; you could split the string
(recipes exist) and carefully call tonumber() on each of them.