Showing results for 
Search instead for 
Did you mean: 

Writing data to a text file from a cluster.

Go to solution

Hello everyone, i have attached the following block that features a cluster consisting of different data types, numeric, string boolen and 1D array. Then i convert the data to a variant data and i create variant array. However when i try to save the data to a text file i get a result that isnt fully readable. I expect a result such as 

Age 12.00
First name  "Ivan"
Second Name "Petrov"
Boolean  TRUE
Array1  1 2 3 2 3 
Array2  "aasd" "sdsd" "sdfdgf" "dfdf"


0 Kudos
Message 1 of 5

Hi Blaze,


why do you expect such a result?

When you convert your cluster into a variant it not just takes the included data, but also all "additional" information (like cluster element labels and datatypes) - and it will also write all this information into the file!


When you don't want all that additional information you need to convert your cluster content into text "manually" - using UnbundleByName followed by FormatIntoString might lead to one solution…

Best regards,

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5

The closest thing will probably be Flatten to JSON or Flatten to XML to get something readable. As GerdW said, there is other meta data that is contained within a cluster that needs to be considered as well. JSON or XML will handle that for you. You can also read that text file back in.

0 Kudos
Message 3 of 5
Accepted by Blaze888

Dear Blaze!


I attached a sample code that produce a similiar result you expect. If you want to use it with variants, you simply have to call the Variant to Data function on the corresponding variant and use the reference of the result cluster. In this case you must wire a cluster type constant which has the same controls as the variant has inside, to the Variant to Data function.


However, as the others pointed out before me. It is easier if you use flatten to string or flatten to xml functions.

Best Regards,

Ferenc Zádori

0 Kudos
Message 4 of 5

Thank you for the time and effort and put in to help me.I tried different functions and i found out flatten to JSON worked the best out for me. 

Best Regards,


0 Kudos
Message 5 of 5