LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build Array of Different Data Types

Guys, sorry for the newbie question, but I am new to LabVIEW. I currently have ~15 elements of different data types (a small array of doubles, Booleans, doubles and strings). My end goal is to output these elements into a csv that Excel can open with the elements all in different cells in a row. Currently, the VI uses a Build Array, and then does a "Write to Spreadsheet File" to write to a text file.

 

Because the data sizes are different, the Build Array function forces concatenation into one string, which I am then struggling to delimit since the data types and sizes are different.  

 

Do I want to use a function besides Build Array to accomplish this? Or what is the best way to write these different elements to a csv?

0 Kudos
Message 1 of 12
(4,564 Views)

Hi jvavra,

 

I currently have ~15 elements of different data types

Convert all those data into strings, then build an array of strings to write it into a CSV file…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(4,550 Views)

Let me see if I've got it: do a "Convert to String" on each input to Build Array BEFORE entering Build Array? And then Build Array *should* recognize that all the data types are now the same, and allow me to NOT concatenate into one string?

0 Kudos
Message 3 of 12
(4,544 Views)

@jvavra wrote:

Guys, sorry for the newbie question, but I am new to LabVIEW. I currently have ~15 elements of different data types (a small array of doubles, Booleans, doubles and strings). My end goal is to output these elements into a csv that Excel can open with the elements all in different cells in a row. Currently, the VI uses a Build Array, and then does a "Write to Spreadsheet File" to write to a text file.

 

Because the data sizes are different, the Build Array function forces concatenation into one string, which I am then struggling to delimit since the data types and sizes are different.  

 

Do I want to use a function besides Build Array to accomplish this? Or what is the best way to write these different elements to a csv?


You wrote "I currently have ~15 elements of different data types (a small array of doubles, Booleans, doubles and strings)".  But you have no such thing because that can't exist.  All elements in an array are the same type.  To get help, post your code.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 12
(4,542 Views)

@jvavra wrote:

Let me see if I've got it: do a "Convert to String" on each input to Build Array BEFORE entering Build Array? And then Build Array *should* recognize that all the data types are now the same, and allow me to NOT concatenate into one string?


You seem to be confusing Build Array with Concatenate String.  But I can't tell what you're doing unless you post your code.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 12
(4,541 Views)

@paul_cardinale wrote:

@jvavra wrote:

Let me see if I've got it: do a "Convert to String" on each input to Build Array BEFORE entering Build Array? And then Build Array *should* recognize that all the data types are now the same, and allow me to NOT concatenate into one string?


You seem to be confusing Build Array with Concatenate String.  But I can't tell what you're doing unless you post your code.


Unless I'm reading it wrong, it appears Build Array does a concatenate automatically if you have elements of different sizes.  

 

See code here. 

0 Kudos
Message 6 of 12
(4,522 Views)

For all of your scalar values put a build array prior to your build array. This will convert the scalar to a 1D array. I believe this will get what you want.

 

You really need to clean up that block diagram. It's really hard to follow as you have lines running backward and it's very large.

0 Kudos
Message 7 of 12
(4,496 Views)

@johntrich1971 wrote:

For all of your scalar values put a build array prior to your build array. This will convert the scalar to a 1D array. I believe this will get what you want.

 

You really need to clean up that block diagram. It's really hard to follow as you have lines running backward and it's very large.


Yeah, I mentioned it in another post, I inherited this mess unfortunately. This is only one VI that's part of a MUCH larger VI. Took me awhile to figure out what it was doing, and how. 

0 Kudos
Message 8 of 12
(4,485 Views)

Read the Help for Build Array.  Note you can choose to "Build" (e.g. 1D + 1D = 2D) or "Concatenate" (1D + 1D = 1D, length = length of 1 + length of 2).

 

Every element in the Array must be of the same Type.  For example, you can't combine a Push Button and a Rocker Switch, nor a Green LED with a Red LED.

 

When Building "vertically" (i.e. not concatenating), the Arrays do not need to be the same length going in, but they will be the same length inside the resulting array (with extra "default values" added to the shorter element).

 

You can learn more about this from the Help on Build Array.

 

Bob Schor

0 Kudos
Message 9 of 12
(4,482 Views)

@jvavra wrote:

@paul_cardinale wrote:

@jvavra wrote:

Let me see if I've got it: do a "Convert to String" on each input to Build Array BEFORE entering Build Array? And then Build Array *should* recognize that all the data types are now the same, and allow me to NOT concatenate into one string?


You seem to be confusing Build Array with Concatenate String.  But I can't tell what you're doing unless you post your code.


Unless I'm reading it wrong, it appears Build Array does a concatenate automatically if you have elements of different sizes.  

 

See code here. 


There's no such thing as "elements of different sizes".

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 10 of 12
(4,477 Views)