01-28-2011 10:50 AM - edited 01-28-2011 10:51 AM
How do you recommend turning an array of clusters (containing only doubles and strings) to a CSV file (or Excel spreadsheet)?
Solved! Go to Solution.
01-28-2011 10:53 AM - edited 01-28-2011 10:54 AM
Unbundle the cluster (in an indexed loop), convert to strings, add required delimiters, write to CSV file. I can't be more specific unless you post your cluster.
01-28-2011 10:55 AM
You could pass the array into a for loop.
Then for each cluster, use Cluster to Array, and pass that array out of the for loop.
It will then auto-index into a 2D array for you.
You can use Write to Spreadsheet File to write this 2D array to a CSV.
01-28-2011 10:57 AM
Will Cluster to Array work with mixed data types? I don't think it's smart enough (or I'm not...).
01-28-2011 11:00 AM
@NIquist wrote:
Will Cluster to Array work with mixed data types? I don't think it's smart enough (or I'm not...).
Umm I'm not sure I didnt try.
But if it doesn't, it wouldn't hurt anything if you just typecasted everything to strings, because you're writing it to a text file anyway, so it won't care
01-28-2011 11:27 AM
Basically what NIquist said, but I would encourage you to use Format Into String, one of those rare moments in LV when the terminals from Unbundle align nicely with the terminals in Format Into String.
Hint: To get the format string, first wire the connections then right click Format Into String and select 'Edit Format String'. The floats and strings are already there for you, just add the commas (or \t) and the \n and you are done.
01-28-2011 12:13 PM
I went with this solution. Easy enough for a temporary solution.
Just thought maybe there was a built-in method that would work on any cluster instead of coding for a specific one.
01-28-2011 12:46 PM
@StevenATK wrote:
I went with this solution. Easy enough for a temporary solution.
Just thought maybe there was a built-in method that would work on any cluster instead of coding for a specific one.
I think the problem lies with the data type(s) that are inside the cluster.
It is difficult to make a single, simple function because clusters can have any number of things inside, not necessarily of the same data type.
They can have simple things inside such as ints, dbls, strings, etc but they could also have nested clusters, arrays, etc which would make it very difficult to write to a file.