POV-Ray : Newsgroups : povray.general : comma separated value file for data input : Re: comma separated value file for data input Server Time
8 May 2024 08:31:49 EDT (-0400)
  Re: comma separated value file for data input  
From: Charles C
Date: 10 Feb 2007 12:05:00
Message: <web.45cdfa7ad81812bf9356f54f0@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
>   It's naturally impossible to know the amount of numbers in the input
> file before the file has been parsed.
>   There are two possible solutions:
>
>   If you can make the program which creates the data file to store the
> amount of values as the first value, that would be the easiest way of
> automatically getting this value in the pov file.
>
>   If that's just not possible, then you can simulate dynamic arrays in
> povray by first creating an array of certain size, reading data into it,
> and if it fills up, create a bigger array, copy the data from the old one
> to this new one, and then continue reading values, and so on. In the end,
> if an exact array (without unused values at the end) is needed, you can
> create an array of that exact size and copy the data there.

In my original reply I went with the assumption that knowing the amount of
data he'd want to display was something he could do manually.  But the docs
for the "#read" keyword reveal kindof a nifty way to do it.  Just add a(n
initialized) counter where the "..." is below, and then re-open the file
and count/read to that value.

Charles

From the docs:
  #fopen MyFile "mydata.txt" read
  #while (defined(MyFile))
    #read (MyFile,Var1,Var2,Var3)
    ...
  #end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.