LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Numerical array to CSV without zero padding

Solved!
Go to solution

I am trying to concatenate then convert 1D arrays of floats to a csv string. The array needs to be a fixed size.

 

When the incoming array is less than the fixed size, I would like the value to be an empty string, so 1,2,3 would come out as "1,2,3,,,,,,,,,,,".

 

The 'Reshape Array' VI zero pads the array however. Is there an easier way to do this?

array to csv.PNG

0 Kudos
Message 1 of 6
(2,479 Views)
Solution
Accepted by topic author stephenb2

Format first, then pad the string array with empty strings using reshape array.

(fixed size is 8 elements each in this example)

 

altenbach_0-1574274444741.png

0 Kudos
Message 2 of 6
(2,473 Views)

That's the wrong function.  Why use Reshape Array?

 

The correct function would be Array Subset.

0 Kudos
Message 3 of 6
(2,472 Views)

@RavensFan wrote:

That's the wrong function.  Why use Reshape Array?

 

The correct function would be Array Subset.


Reshape array can pad or trim. Array subset can only trim.

0 Kudos
Message 4 of 6
(2,464 Views)

I missed the part that they wanted empty strings.  I was only seeing the problem about 0's coming from the reshape array when the array was too short.

0 Kudos
Message 5 of 6
(2,457 Views)

Taking advantage of the fact that the default value of a string array for reshape array is an empty string. Thanks altenbach.

0 Kudos
Message 6 of 6
(2,445 Views)