LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Spreadsheet to XML Cluster

Hi,

I am trying to find an automated method of converting a spreadsheet file containing a signals list into an XML format that corresponds to a LabVIEW cluster. See spreadsheet file.csv for example of signals list.

 

The cluster is made up of an array of three clusters (each containing 4 elements: name, data type, value and description) and an array cluster of group listings with 2 elements (group and array of tag names).

 

See Cluster to XML.vi for  example. The output string shows the required format in XML.

 

First off, I've attempted to create the array of clusters. I'm not sure if this is the best method but this is what I've tried so far:

 

  • read delimited spreadsheet vi to bring the elements into LabVIEW.
  • Index array to select each row
  • Array to cluster
  • Build array to get cluster of arrays (tags)

For Signal List 1, see signal list to XML (simple).vi, I indexed each row and inserted the elements into the cluster of arrays. For Signal List 2, see Signal List to XML.vi, I attempted to automate the process, incrementing the index value with each iteration. I tried this with a for loop, however it only allowed me to return a string value rather than array. When I use a while loop, I am able to insert the first cluster in the Tags2 but the process ends there.

 

How can I repeat the process for N number of rows?

 

Also another problem is I am unable to assign names to the elements in the clusters (name, data type, value and description). I tried indexing the arrays into elements and bundling by name, but only gives the name string as an option. I've tried to look online, but can't find much guidance.

 

How can I assign names to the elements?

 

Any help will be much appreciated!

Thanks

Lisa

 

 

0 Kudos
Message 1 of 3
(1,393 Views)

I'm not entirely sure what you are trying to do, but have some comments that might be helpful.

  • All the elements of your Spreadsheet are strings.  In particular, if all of the "Type" entries are Boolean, then this column could be eliminated and the Value could be a true Boolean, True or False, making the Cluster a Cluster of two strings and a Boolean.
  • Your Cluster (as shown in Cluster 1a) should be made into a TypeDef (which I have done, and named it Signal) so you can use it in your code.
  • Your spreadsheet, when read (Signal List 1) is an Array of Clusters.  So create an Array of Clusters, and save that Array in XML (which should sub-parse the Cluster elements for you).

Signal List.png

 

Bob Schor

0 Kudos
Message 2 of 3
(1,353 Views)

Hi Bob,

Many thanks for your help.

I misunderstood the task given to me, so turns out I will be using python rather than labview to perform the csv to XML conversion.

Though I appreciate your time and suggestions!

Kind Regards,

Lisa

0 Kudos
Message 3 of 3
(1,324 Views)