My problem is that I want to take a float value from a csv file. I want to put this float value, in the hypershade utility “floatConstant”. Especially in the “float” box. I want to do this by Mel/ Python.
The first part , how i can take the value from the csv I think that i am near. I think the MEl code is
Interesting question. Most definetly you want to do this with python. I’ll ha e a look tomorrow if someone else doesn’t have the answer readily available.
Below is my code
/////////////////////////////////////////////////////////////////////////
global proc float[] get_float_from_csv(string $csv)
{
if (!file -q -ex $csv)
{
error ("File is not found : " + $csv);
return {};
}
float $float_values[];
string $lines[] = `freadAllLines $csv`;
for ($line in $lines)
{
string $elements[] = `stringToStringArray $line ","`;
for ($elem in $elements)
{
string $match_float = `match "[0-9]+.[0-9]+" $elem`;
if (`size $match_float` == 0)
{
continue;
}
$float_values[size($float_values)] = (float)$elem;
}
}
return $float_values;