|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Here's what I have so far, which errors on the third line of the data file with
"Parse error: Expected 'float, vector, or string literal',, found instead"
//Initialize with safe values
#declare Lines_In_File = 0;
#declare Xval = 1;
#declare Yval = 1;
#declare Zval = 1;
// Sample data, X, Y, Z
//0.128236817,0.17343048,1.06941009
//-0.109255917,-0.005383651,0.765301253
//0.059836132,0.172405022,0.976029181 <--- Errors on this line
//Find how many lines in the file
#fopen MyFile "drop13.csv" read
#while (defined(MyFile))
#read (MyFile,Xval,Yval,Zval)
#declare Lines_In_File=Lines_In_File+1 ;
#end
#fclose MyFile
// Having Lines_In_File now holding the lines count
#declare clock=0;
#declare Count=0;
// Read the Nth line
#declare Read_Line = int((1/Lines_In_File)*clock)
#fopen MyFile "bang.csv" read
#while (defined(MyFile))
#while (Count<Line)
#read (MyFile,Xval,Yval,Zval)
#declare Count=Count+1
#end
#end
#fclose MyFile
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Dave VanHorn" <mic### [at] gmailcom> wrote in message
news:web.47bc95f886d65c51a08ed15e0@news.povray.org...
>
> Here's what I have so far, which errors on the third line of the data file
> with
> "Parse error: Expected 'float, vector, or string literal',, found instead"
> ...
>
> // Sample data, X, Y, Z
> //0.128236817,0.17343048,1.06941009
> //-0.109255917,-0.005383651,0.765301253
> //0.059836132,0.172405022,0.976029181 <--- Errors on this line
>
>
If this is what the file looks like it looks like, you're missing commas at
the end of each line.
POV-Ray disregards the line throws, so I suspect it would read past the
first doing a subtraction due to the minus sign starting the second line.
When it hits the end of the second line it'll concatenate two numbers with
decimal points in both and doesn't know how to handle that.
If the whole file is XYZ coordinates you might want to code it up as vectors
(depending upon what you want to do with them). e.g:
<0.128236817,0.17343048,1.06941009>,
<-0.109255917,-0.005383651,0.765301253>,
<0.059836132,0.172405022,0.976029181> ,
... etc.
In which case you can read in a single variable containing the coordinates.
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> If this is what the file looks like it looks like, you're missing commas at
> the end of each line.
Is there any way to make it work without that?
My data files are >1000 lines, manually fixing it would be awful.
> If the whole file is XYZ coordinates you might want to code it up as vectors
> (depending upon what you want to do with them). e.g:
> <0.128236817,0.17343048,1.06941009>,
> <-0.109255917,-0.005383651,0.765301253>,
> <0.059836132,0.172405022,0.976029181> ,
I don't have any way to make the data come to me in this format.
Maybe a different way to use the #read?
Here's the current version:
//Find how many lines in the file
#fopen MyFile "drop13.csv" read
#while (defined(MyFile))
#read (MyFile,Xval,Yval,Zval)
#debug concat("Just read line ", str(Lines_In_File,1,0), "\n")
#declare EX=str(Xval,12,9);
#declare WY=str(Yval,12,9);
#declare Zee=str(Zval,12,9);
#debug concat(EX," ",WY," ",Zee,"\n")
#declare Lines_In_File=Lines_In_File+1 ;
#end
#fclose MyFile
// Having Lines_In_File now holding the lines count
#declare Count=0;
/*
#declare Read_Line = 1; //int((1/Lines_In_File)*Clock);
#fopen MyFile "drop13.csv" read
#while (defined(MyFile))
#while (Count<Read_Line)
#read (MyFile,Xstr,Ystr,Zstr)
#declare Count=Count+1;
#end
#end
#fclose MyFile
Here's the debug output:
Bounding boxes.......On Bounding threshold: 3
Light Buffer.........On
Vista Buffer.........On Draw Vista Buffer....Off
Antialiasing.........On (Method 1, Threshold 0.300, Depth 3, Jitter 1.00)
Clock value: 0.000 (Animation off)
Just read line 1
0.128236817 0.173430480 1.069410090
Just read line 2
0.109255917 -0.005383651 0.765301253
File: drop13.csv Line: 3
File Context (5 lines):
0.128236817,0.17343048,1.06941009
-0.109255917,-0.005383651,0.765301253
0.059836132,
Parse Error: Expected 'float, vector, or string literal', , found instead
Total Scene Processing Times
Parse Time: 0 hours 0 minutes 0 seconds (0 seconds)
Photon Time: 0 hours 0 minutes 0 seconds (0 seconds)
Render Time: 0 hours 0 minutes 0 seconds (0 seconds)
Total Time: 0 hours 0 minutes 0 seconds (0 seconds)
CPU time used: kernel 0.02 seconds, user 0.05 seconds, total 0.06 seconds
POV-Ray finished
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>> If this is what the file looks like it looks like, you're missing commas at
>> the end of each line.
>
> Is there any way to make it work without that?
No.
> My data files are >1000 lines, manually fixing it would be awful.
Manually? Of course nobody would waste his time doing that *manually*.
Are you on Windows?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Manually? Of course nobody would waste his time doing that *manually*.
>
> Are you on Windows?
Unfortunately, XP pro.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hmm.. I'm wondering if pov can read each line as text, append the comma, and
write it to an intermediate file..
Read bang1.csv, append comma, write to data.csv, then read the values in from
data.csv.. Something like that.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Hmm.. I'm wondering if pov can read each line as text, append the comma, and
> write it to an intermediate file..
>
> Read bang1.csv, append comma, write to data.csv, then read the values in from
> data.csv.. Something like that.
>
Nope, POV-Ray can't read line-by-line...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Nicolas Alvarez" <nic### [at] gmailisthebestcom> wrote in message
news:47bcab82$1@news.povray.org...
>> Hmm.. I'm wondering if pov can read each line as text, append the comma,
>> and
>> write it to an intermediate file..
>>
>> Read bang1.csv, append comma, write to data.csv, then read the values in
>> from
>> data.csv.. Something like that.
>>
>
> Nope, POV-Ray can't read line-by-line...
Hi Dave,
Nicolas is right that the POV-Ray parser can't do this, but the Windows
POV-Ray editor can, and most professional text editors can too.
If you've got a decent text editor (for example Ultraedit) that recognises
line end/carriage return characters, you can do a global change, changing
all carriage returns to a comma followed by a carriage return. Don't forget
to delete the last one at the end of the last line or you'll be adding an
unwanted field.
Alternatively you can use a columnar editor (e.g. Ultraedit or the Windows
POV-Ray editor) to add a comma to the front of each line. Because the
POV-Ray #read directive ignores line end characters it's not going to care
if the comma is at the end of one line or the start of the next.
To do this in the Windows POV-Ray editor you can click at the beginning of
the second line (not the first line or you'll add a superfluous field to the
start of the first line). Then scroll down to the bottom of the file by
clicking and dragging the vertical scroll bar (don't tab down or page down
or anything else that moves the caret). Use Ctl-Shift-Click to the start of
the last line. You should get a thick black line at the start of all lines
from line 2 to the bottom of the file. Anything you now type should get
added to the start of each selected line, so type a single comma then click
anywhere else to come out of columnar edit mode.
Hey presto! You should be able to change a file in this way in about 10
seconds (with a little practice) no matter how big it is. If you have
hundreds of files to change you'll probably need an editor that can do
multi-file global changes (like Ultraedit).
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>> If this is what the file looks like it looks like, you're missing commas at
>> the end of each line.
>
> Is there any way to make it work without that?
> My data files are >1000 lines, manually fixing it would be awful.
Try this:
http://stuff.povaddict.com.ar/comma-add.php
I tried to give you the link last night, but I had a power outage right
before I could click Send.
(power outage lasted over 12 hours, and the power company doesn't care
about all the lost food on the fridge... great)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ok, just so it's out here and useful for someone else, here's my routine that
inputs triplets of data points from an accelerometer, finds the peak, and
renders 500 samples either side of the peak.
We did a small linux thing to fix the CSV output, but it would be nice if pov
could read CSV files output by excel in the future, in the form of :
Data1, Data2, Data3
Data1, Data2, Data3
Thanks tons for the help!
//Initialize with safe values
#declare Lines_In_File = 0;
#declare MaxX=0;
#declare MaxY=0;
#declare MaxZ=0;
#declare Zabs=0;
#declare YPeak=-10000;
#declare PeakLine=0;
//Find how many lines in the file
#fopen MyFile "drop3.csv" read
#while (defined(MyFile))
#read (MyFile,Xval,Zval,Yval) // Z is up/down
// Find max Z val
#declare Zabs=abs(Zval);
#if (Zval>Zabs)
#declare Zabs=Zval;
#end
// Find max Y val
#if (Yval>YPeak)
#debug concat("New Peak= ", str(Yval,1,6), " Old= ",str(YPeak,1,6)," in line
",str(Lines_In_File,1,0), "\n")
#declare YPeak=Yval;
#declare PeakLine=Lines_In_File; //off by one, but I don't care
#end
// Find max X val
#declare Xabs=abs(Xval);
#if (Xval>Xabs)
Xabs=Xval
#end
// Count a line
#declare Lines_In_File=Lines_In_File+1 ;
#end
#debug concat("Just Counted ", str(Lines_In_File,1,0), " lines in the file",
"\n")
#debug concat("REMEMBER TO SET THE -KFF parm to ", str(Lines_In_File,1,0),
"\n")
#debug concat("Peaks X=", str(Xabs,4,9)," Y=",str(YPeak,4,9),"
Z=",str(Zabs,4,9), "\n")
#debug concat("REMEMBER to check this against the scene view! ","\n")
#debug concat("Peak impact in line ", str(PeakLine,1,0), "\n")
#fclose MyFile
// Having Lines_In_File now holding the lines count
#if (PeakLine < 501)
#declare Start = PeakLine;
#else
#declare Start = PeakLine-500; //500 = 0.1 sec before impact peak
#end
#if (Start+1000 < Lines_In_File)
#declare End = Start+1000; //Lines_In_File;
#else
#declare End = Lines_In_File
#end
#declare My_Clock = Start+(End-Start)*clock;
#declare Count = 0;
#declare Read_Line = int(My_Clock);
#debug concat("Start = ", str(Start,5,2),"\n")
#debug concat("End = ", str(End,5,2),"\n")
#debug concat("REMEMBER TO SET THE -KFF parm to ", str((End - Start),1,0), "\n")
#debug concat("My_Clock = ", str(My_Clock,5,2),"\n")
#debug concat("Read_Line = ", str(Read_Line,5,2),"\n")
#fopen MyFile "drop3.csv" read
#while (Count<Read_Line)
#read (MyFile,Xval,Zval,Yval) // In POV, X and Z are horizontal, Y is vertical
#declare Count=Count+1;
#end
#fclose MyFile
//debugging output
#debug concat("Just Read line ", str(Count,1,0), "\n")
#declare EX=str(Xval,12,9);
#declare WY=str(Yval,12,9);
#declare Zee=str(Zval,12,9);
#debug concat(EX," ",WY," ",Zee,"\n")
// Flip polarity on Yval
#declare Yval = (0 - Yval);
//Trap zero case which would make degenerate cylinder
#if (Xval+Yval+Zval=0)
Xval=0.001
Yval=0.001
Zval-0.001
#end
//Scaling
#declare ScaleVal = 1;
#declare Xval=Xval/ScaleVal;
#declare Yval=Yval/ScaleVal;
#declare Zval=Zval/ScaleVal;
From here, I build the scene, using Xval, Yval, and Zval to stretch an arrow in
the appropriate direction.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|