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 13:54:08 EDT (-0400)
  Re: comma separated value file for data input  
From: Mark Birch
Date: 10 Feb 2007 15:20:00
Message: <web.45ce27e5d81812bfdbc5fd0e0@news.povray.org>
"Eric" <[firstname]@theothersideofthenet.com> wrote:
> Although far from new to POV-Ray (programmed first rendering in about 1996),
> I am an infrequent user and thus a novice.  Right now I'm returning to it to
> produce some 3D statistical graphs.  It would be really convenient for me
> read data in from some sort of two-dimensional data file (a table).  Comma
> separated value files (.CSV) are commonly used for this.  Is there any
> convenient way to read a CSV file into some sort of data container (an
> array of arrays? or can MATRIX be used other than for transforms?)
>
> Thanks!
> -Eric

Reading the data in one value at a time is unnecessary.
If you can format the text to read like a proper array declaration, then you
can simply #include that file:

// data file, saved as "Myarray.inc"
#declare Myarray = array[5][5]
{
  (1, 2, 3, 4, 5},
  {5, 4, 3, 2, 1},
  {6, 7, 8, 9, 0},
  {7, 4, 6, 3, 4},
  {9, 4, 2, 5, 7}
}
// -----------------------------


// Main POV file
#include "Myarray.inc"


Post a reply to this message

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