LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write string to csv

Solved!
Go to solution

Hello everyone,

I am struggling with an issue in Labview...I am trying to write a string of numbers to a csv file, but I want to be able cu arrange the string by a number of columns inputed from an user. The data.txt is just a sample, the initial file is much bigger, the data.csv is the only thing I managed to write, and I want when I input from a control for example 4 columns to rearrange the csv into my desired.csv. I appreciate any ideas or help that I can get.

 

Download All
0 Kudos
Message 1 of 6
(4,983 Views)

Reshape Array to lenth(x)/3,3 then it should look as you desire.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 6
(4,968 Views)

Can you please explain with more details, because I just started learning labview...I know that with the reshape array function I can change the dimension, but where can I change the length?

0 Kudos
Message 3 of 6
(4,959 Views)
Solution
Accepted by ierdna

See if this makes any sense.  I am just getting the number of items in the original file and dividing by the number of desired columns to get the number of rows there will be.  From there, it is just a simple Reshape Array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 6
(4,947 Views)

@ierdna wrote:

I know that with the reshape array function I can change the dimension, but where can I change the length?


I'm not sure what you mean by your question -- are you talking about the input array to the function, or the "reshaped" array?

 

To change the size of an (input) array, you can add elements to it (using Build Array, or one of the "Insert" functions).  You can create arrays of a specific size using Initialize Array, Build Array, or a For loop.

 

If you have an Input Array of size N, you can create an output Array of size M (which may or may not be equal to N) by using Reshape Array.  For the sake of discussion, let's assume N is a 1D array and M is a 2D array, M = a*b.  As the Help for Reshape Array clearly states, the output array will always be of size M = a*b.  If M = N, then all the elements of N will be represented in M, with no "default values".  If N < M, there will be default values (0 for numeric, False for boolean, empty for strings) for the last N-M entries, while if N > M, the last N-M entries will be missing, and M will be a truncated version of N.

 

Bob Schor

Message 5 of 6
(4,945 Views)

Yes this is exactly what I wanted, it works perfectly. Thank you very much crossrulz for your help!

0 Kudos
Message 6 of 6
(4,934 Views)