POV-Ray : Newsgroups : povray.general : Povray & CSV files Server Time
30 Jul 2024 10:16:25 EDT (-0400)
  Povray & CSV files (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: gregjohn
Subject: Povray & CSV files
Date: 20 May 2009 21:50:01
Message: <web.4a14b288ca8116b934d207310@news.povray.org>
I want to make my own graph-plotting routine in povray using some CSV files that
are frequently generated at work.

I know how to do this if I were to go to the trouble of editing the file and
inserting #declare's and {'s into the text.  I don't want to do this on a
regular basis, and might like to share the pov with folks who aren't as
pov-savvy right now.

Any tips on how to get the data into povray from a typical standard CSV?


Post a reply to this message

From: Jim Henderson
Subject: Re: Povray & CSV files
Date: 20 May 2009 22:06:19
Message: <4a14b71b$1@news.povray.org>
On Wed, 20 May 2009 21:47:20 -0400, gregjohn wrote:

> I know how to do this if I were to go to the trouble of editing the file
> and inserting #declare's and {'s into the text.  I don't want to do this
> on a regular basis, and might like to share the pov with folks who
> aren't as pov-savvy right now.

If it's just a question of inserting some stuff into the text, have a 
look at using something like awk or perl to process the CSV data to 
generate the POV stuff.

Jim


Post a reply to this message

From: Mike Williams
Subject: Re: Povray & CSV files
Date: 21 May 2009 02:17:10
Message: <EW7XzWB+CPFKFwKu@econym.demon.co.uk>
Wasn't it gregjohn who wrote:
>I want to make my own graph-plotting routine in povray using some CSV 
>files that
>are frequently generated at work.
>
>I know how to do this if I were to go to the trouble of editing the file and
>inserting #declare's and {'s into the text.  I don't want to do this on a
>regular basis, and might like to share the pov with folks who aren't as
>pov-savvy right now.
>
>Any tips on how to get the data into povray from a typical standard CSV?

The significant difference between standard CSV format and the file 
format that can be read by POV with #read is that POV doesn't consider a 
line break to be a field separator. So you need to add a comma at the 
end of every line.

Another problem is that CSV files can contain commas within quoted 
strings. I suspect that #fread may treat those as field separators. I 
imagine that working round that might be quite messy if your data 
contains commas. (I was going to check how #fread handles commas inside 
quoted strings, but my copy of POV seems to have suddenly died).

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: clipka
Subject: Re: Povray & CSV files
Date: 21 May 2009 13:30:00
Message: <web.4a158f8e2dfb0a1ae1d5d3040@news.povray.org>
"gregjohn" <pte### [at] yahoocom> wrote:
> Any tips on how to get the data into povray from a typical standard CSV?

#read should be able to do the job, if the file is nice straightforward CSV.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Povray & CSV files
Date: 21 May 2009 16:51:27
Message: <4a15becf$1@news.povray.org>
clipka wrote:
> "gregjohn" <pte### [at] yahoocom> wrote:
>> Any tips on how to get the data into povray from a typical standard CSV?
> 
> #read should be able to do the job, if the file is nice straightforward CSV.

Except if the file contains unquoted strings. #read seems to require
quotes even if no delimiter occurs in the text. Stumbled across that one
with an astronomical database which included the object designation in
the CSV output.


Post a reply to this message

From: gregjohn
Subject: Re: Povray & CSV files
Date: 21 May 2009 17:55:01
Message: <web.4a15cd1e2dfb0a1a34d207310@news.povray.org>
"clipka" <nomail@nomail> wrote:
> "gregjohn" <pte### [at] yahoocom> wrote:
> > Any tips on how to get the data into povray from a typical standard CSV?
>
> #read should be able to do the job, if the file is nice straightforward CSV.


Really? Suppose it's a list like this, how could you actually get these data
"into" povray?


1 , -2 , -8.4715E-05 , 57983.2925
2 , -1.98 , -8.5116E-05 , 56354.0494


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Povray & CSV files
Date: 21 May 2009 18:26:53
Message: <4a15d52d$1@news.povray.org>
gregjohn wrote:
> Really? Suppose it's a list like this, how could you actually get these data
> "into" povray?
> 
> 1 , -2 , -8.4715E-05 , 57983.2925
> 2 , -1.98 , -8.5116E-05 , 56354.0494

#fopen CSV_FILE "file.csv" read

   // For each line you wish to read:
   #read(CSV_FILE, INDEX, V1, V2, V3)
   // Do something with the data


Instead of simple variables, you can also use arrays,
but then you need to create the array in advance. This
requires two passes if you don't know the number of
elements in advance.


Post a reply to this message

From: Mike Williams
Subject: Re: Povray & CSV files
Date: 22 May 2009 01:29:38
Message: <dqrR8iB$WjFKFwKm@econym.demon.co.uk>
Wasn't it gregjohn who wrote:
>"clipka" <nomail@nomail> wrote:
>> "gregjohn" <pte### [at] yahoocom> wrote:
>> > Any tips on how to get the data into povray from a typical standard CSV?
>>
>> #read should be able to do the job, if the file is nice straightforward CSV.
>
>
>Really? Suppose it's a list like this, how could you actually get these data
>"into" povray?
>
>
>1 , -2 , -8.4715E-05 , 57983.2925
>2 , -1.98 , -8.5116E-05 , 56354.0494

As mentioned upthread, in order to be read by POVRay the data needs to 
be preprocessed to change it to

1 , -2 , -8.4715E-05 , 57983.2925 ,
2 , -1.98 , -8.5116E-05 , 56354.0494 ,

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: "Jérôme M. Berger"
Subject: Re: Povray & CSV files
Date: 22 May 2009 03:05:42
Message: <4a164ec6@news.povray.org>
Mike Williams wrote:
> Wasn't it gregjohn who wrote:
>> I want to make my own graph-plotting routine in povray using some CSV 

>> files that
>> are frequently generated at work.
>>
>> I know how to do this if I were to go to the trouble of editing the 
>> file and
>> inserting #declare's and {'s into the text.  I don't want to do this o
n a
>> regular basis, and might like to share the pov with folks who aren't a
s
>> pov-savvy right now.
>>
>> Any tips on how to get the data into povray from a typical standard CS
V?
> 
> The significant difference between standard CSV format and the file 
> format that can be read by POV with #read is that POV doesn't consider 
a 
> line break to be a field separator. So you need to add a comma at the 
> end of every line.
> 
> Another problem is that CSV files can contain commas within quoted 
> strings. I suspect that #fread may treat those as field separators. I 
> imagine that working round that might be quite messy if your data 
> contains commas. (I was going to check how #fread handles commas inside
 
> quoted strings, but my copy of POV seems to have suddenly died).
> 
	And finally, depending on your os language settings and the 
software you use to create the CSV, the format may change 
completely. For example in France, Excel creates CSV where the 
separator is the semicolon and the coma is used as a decimal point...

		Jerome
-- 
mailto:jeb### [at] freefr
http://jeberger.free.fr
Jabber: jeb### [at] jabberfr


Post a reply to this message


Attachments:
Download 'us-ascii' (1 KB)

From: Christian Froeschlin
Subject: Re: Povray & CSV files
Date: 23 May 2009 14:56:57
Message: <4a1846f9$1@news.povray.org>
Mike Williams wrote:

> As mentioned upthread, in order to be read by POVRay the data needs to 
> be preprocessed to change it to
> 
> 1 , -2 , -8.4715E-05 , 57983.2925 ,
> 2 , -1.98 , -8.5116E-05 , 56354.0494 ,

I didn't find that necessary when reading in the galaxy positions
for my recent "Local Neighborhood" image. I used one #read per line.
The file had unix line endings, although that shouldn't matter.


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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