|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I've got a large ASCII txt file. Every row is an integer. I have forgotten
how to get povray to read the file so that povray can use them as declared
variables.
I know I could go in and edit the file and have it say something like
#declare My_Array[1000]={item,item...}. If I were to do that I could
simply #include the file. But I have an application where I would be
doing a bunch of them and would like to avoid editing every single one of
them.
thanks.
Post a reply to this message
|
|
| |
| |
|
|
From: Warp
Subject: Re: Syntax for reading a large file of numbers.
Date: 18 May 2007 16:50:40
Message: <464e11a0@news.povray.org>
|
|
|
| |
| |
|
|
gregjohn <pte### [at] yahoocom> wrote:
> I've got a large ASCII txt file. Every row is an integer. I have forgotten
> how to get povray to read the file so that povray can use them as declared
> variables.
http://povray.org/documentation/view/3.6.1/238/
Note that if your input has negative numbers, they must be comma-separated
(else they will be interpreted as a mathematical expressions).
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
gregjohn nous apporta ses lumieres en ce 18 / 05 / 2007 16:21:
> I've got a large ASCII txt file. Every row is an integer. I have forgotten
> how to get povray to read the file so that povray can use them as declared
> variables.
>
> I know I could go in and edit the file and have it say something like
> #declare My_Array[1000]={item,item...}. If I were to do that I could
> simply #include the file. But I have an application where I would be
> doing a bunch of them and would like to avoid editing every single one of
> them.
>
> thanks.
>
>
>
>
>
You can do this:
#declare My_Array[1000]={#include "Your_text_file.txt"}
It's safer to generate your file as a comma separated list, that way, a negative
value wont get substracted from the preceding one. If your file is not comma
separated, a search and replace can be done where you replace "/n" by ",".
--
Alain
-------------------------------------------------
You know you've been raytracing too long when your personal correspondence to
friends starts out with #Dear Linda =
Ken Tyler
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Alain" <ele### [at] netscapenet> wrote in message
news:464e1981$1@news.povray.org...
You know you've been raytracing too long when your personal correspondence
to
> friends starts out with #Dear Linda =
> Ken Tyler
Heh, good ol' Ken, I miss his humour.
~Steve~
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Alain <ele### [at] netscapenet> wrote:
> You can do this:
> #declare My_Array[1000]={#include "Your_text_file.txt"}
>
Okay. This syntax works for a short array:
#declare That_Array=array[5]{1,2,3,4,5}
But for my actual big file, which Notepad2 tells me is 14405 lines long:
#declare My_Array=array[14406]{#include "c:My_Include_File.ppp"}
.... gives me an error message:
"Parse Error: Insufficient number of initializers." I get that with
14404,14405, and a quazillion in the []'s.
Warp's reference to the docs points me to a more painstaking process. I
could do that, but still wondering if there were a quick trick like the one
you suggested, but with different syntax.
Post a reply to this message
|
|
| |
| |
|
|
From: Warp
Subject: Re: Syntax for reading a large file of numbers.
Date: 19 May 2007 14:22:02
Message: <464f404a@news.povray.org>
|
|
|
| |
| |
|
|
gregjohn <pte### [at] yahoocom> wrote:
> Warp's reference to the docs points me to a more painstaking process.
How is it painstaking? It requires something like 5 lines of code.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it gregjohn who wrote:
>Alain <ele### [at] netscapenet> wrote:
>
>> You can do this:
>> #declare My_Array[1000]={#include "Your_text_file.txt"}
>>
>
>Okay. This syntax works for a short array:
>#declare That_Array=array[5]{1,2,3,4,5}
>
>But for my actual big file, which Notepad2 tells me is 14405 lines long:
>
>#declare My_Array=array[14406]{#include "c:My_Include_File.ppp"}
>
>.... gives me an error message:
>
>"Parse Error: Insufficient number of initializers." I get that with
>14404,14405, and a quazillion in the []'s.
You could try a very low number which should give you a "No matching }"
error.
As you've seen, if you use a high number, you get "Insufficient number
of initialisers".
You could then try a binary chop to search for the actual number of
entries.
What might be happening is that you've got some negative numbers. POV
treats
123
-2
as an expression that evaluates to 121 if there are no commas.
If that's the case, then you can globally replace "-" with ",-" in a
copy of the data file.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mike Williams <nos### [at] econymdemoncouk> wrote:
>
> You could try a very low number which should give you a "No matching }"
> error.
>
> As you've seen, if you use a high number, you get "Insufficient number
> of initialisers".
>
> You could then try a binary chop to search for the actual number of
> entries.
>
>
> What might be happening is that you've got some negative numbers.
Thanks, but all the values are between 1 and 255.
I have been tinkering around since then. I'm wondering if my previous error
were that it couldn't find the file (am using the Windows version after
being in linux for quite a while and might not have had the right filename
syntax). But now that I've moved the file to the same directory as my pov
file it still chokes. Only now the error is "Parse Error: Expected 'object
or directive', float function 'float constant' found instead." POV-Win puts
a yellow mark at the first line of the included file.
My hunch is that syntax is unworkable. It is "too elegant". The "five lines
of code" is the way to go.
I believe that the
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
#declare My_Array = array[15000];
#fopen Handle "data_non.csv" read
#local c = 0;
#while (defined(Handle))
#read (Handle, Value)
#declare My_Array[c]=Value;
#local c=c+1;
#end
#fclose Handle
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Tim Attwood" <tim### [at] comcastnet> wrote:
> #declare My_Array = array[15000];
> #fopen Handle "data_non.csv" read
> #local c = 0;
> #while (defined(Handle))
> #read (Handle, Value)
> #declare My_Array[c]=Value;
> #local c=c+1;
> #end
> #fclose Handle
Thanks, Tim. I doubt I ever wouldda figured THAT out on my own.
The odd thing about this is that for a 14400 record file, the value of "c"
is 7200. It is successfully reading every other number.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |