POV-Ray : Newsgroups : povray.bugreports : initialise array from csv file Server Time
24 Sep 2021 05:38:31 EDT (-0400)
  initialise array from csv file (Message 1 to 2 of 2)  
From: jr
Subject: initialise array from csv file
Date: 5 Sep 2021 07:40:00
Message: <web.6134ab6b41a27e515e0fed26cde94f1@news.povray.org>
hi,

I am trying to initialise an array via an '#include', as described in clipka's
message <http://news.povray.org/52dab911%40news.povray.org>.  but, no dice with
the three versions I tried: v3.8 alpha.9945627 and beta.2, and v3.7.0.8.

the test data:
$ cat tst.csv
1,2,3,4,
5,6,7,8,
9,10,11,12,
13,14,15,16
$

in the scene I use:

#declare arr_ = array [16] { #include "tst.csv" };

I get two different error messages, v3.7.0.8: "Parse Error: Insufficent number
of initializers".  and for the v3.8 POV-Ray's: "Parse Error: Expected 'array
initializer element', # found instead".


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: initialise array from csv file
Date: 5 Sep 2021 12:40:00
Message: <web.6134f24d551ab7c61f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> I am trying to initialise an array via an '#include', as described in clipka's
> message <http://news.povray.org/52dab911%40news.povray.org>.  but, no dice with
> the three versions I tried: v3.8 alpha.9945627 and beta.2, and v3.7.0.8.
>
> the test data:
> $ cat tst.csv
> 1,2,3,4,
> 5,6,7,8,
> 9,10,11,12,
> 13,14,15,16
> $
>
> in the scene I use:
>
> #declare arr_ = array [16] { #include "tst.csv" };
>
> I get two different error messages, v3.7.0.8: "Parse Error: Insufficent number
> of initializers".  and for the v3.8 POV-Ray's: "Parse Error: Expected 'array
> initializer element', # found instead".
>
>
> regards, jr.

I think that just because of the way the parser works, certain implementations
and syntax structures are allowed - and able to be properly recognized/tokenized
and accepted by the parser, and others aren't.

You may have to resort to reading in your csv file with a loop and individually
assigning array elements.

try getting rid of the [16] and see what that gets you.
try your nice little () parsing trick
maybe a macro inside the {} would work

I got tied up with a surprise project, and it's eating up my weekend.


- Bill


Post a reply to this message

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