|
![](/i/fill.gif) |
Am 18.01.2014 17:58, schrieb gregjohn:
> I work with a lot of generated CSV files. I'm getting tired of all the mouse
> clicks required to import it into Excel, and into an intelligible graph. I'd
> like to write my own povray file for graphing, perhaps one that is always
> perfect in "readability" no matter what render pixel size you pick.
>
> What's the quickest way of getting a CSV-formatted data file into povray? (If I
> have to do even a small amount of editing of the CSV by hand, it ruins the
> benefit of the project.)
If the CSV data doesn't happen to contain trailing commas, you're out of
luck with official POV-Ray.
If you do have trailing commas (or can arrange to add them
automatically, using e.g. a unix call to sed), and also know how many
items you'll have, the fastest way is probably to populate an array with
the data using #include, then go on from there:
#declare MyArray = array[Rows * Columns] {
#include "MyData.csv"
}
If you do have trailing commas but don't know how many items to read,
you'll probably need to resort to #read.
If you don't have trailing commas, you might want to have a look
UberPOV's plaintext reading feature, which allows you to #read arbitrary
ASCII files line by line.
Maybe the quickest way to proceed from there is to write the lines right
back into a temporary file with added trailing commas, and then either
#include that file into an array (you can determine the number of items
by counting the lines in the previous steps) or #read it as a CSV as
outlined above.
(P.S.: Note that on-topic posts are off-topic in p.off-topic :-P)
Post a reply to this message
|
![](/i/fill.gif) |