LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write formatted 2D data into a file

Solved!
Go to solution

Hello,

 

Here is emulation of an extract of my testbed (where data should be saved into a file for postprocessing).

Here are keypoints:

  • while running, the data are accumulated in a 2D array, where column_0 - the iteration number (integer value), column_1 ... column_3 - measured data (float values)
  • on button STOP click this array is saved into a file

The problem I've met in this example - the data in all columns are saved in floating point format (please, see the screenshot below)

How to save column_0 in integer format, other columns - in floating point ?

 

Thanks

 

 

write_2D_data_into_file (0).png

 

write_2D_data_into_file (0).JPG

0 Kudos
Message 1 of 18
(4,083 Views)

You can't store in one array different data type (see red dot mean type cast). So you can form 2 arrays or before writing split array and convert dbl to int.

 

Also, why you use event-structure out of loop? Your code wil work without it.

Message 2 of 18
(4,070 Views)

Thanks

Indeed event struct  it's useless.

Concerning split arrays I didn't properly understand what you mean.

If I split 2 arrays and convert column_0 to integer, then how to proceed further ?

In the example below I tried to format splitted arrays into strings, but unfortunately write block doesn't support strings

 

write_2D_data_into_file (1).png

 

0 Kudos
Message 3 of 18
(4,057 Views)

Use "built array" instead of "concatenate string". This created a 2D array. transpose if desired. the file tool accepts 2D array of strings.

 

(A file is just a long 1D string, so to get better control, just format it all in memory, delimiters and all, and then write it to a plain text file.)

0 Kudos
Message 4 of 18
(4,049 Views)

Even more simple - without FOR loop ... but still 1st column is formatted as float.

 

write_2D_data_into_file (2).png

0 Kudos
Message 5 of 18
(4,048 Views)
Solution
Accepted by topic author Pavel_47

I think this way to form array and string better.file.png

 

When you use "insert into array" each iteration you waste memory and time

0 Kudos
Message 6 of 18
(4,040 Views)

altenbach a écrit :

Use "built array" instead of "concatenate string". This created a 2D array. transpose if desired. the file tool accepts 2D array of strings.

 

(A file is just a long 1D string, so to get better control, just format it all in memory, delimiters and all, and then write it to a plain text file.)


Build doesn't work (if I correctly understood your suggestion)

 

 

write_2D_data_into_file (3).png

 

write_2D_data_into_file (1).JPG

 

 

0 Kudos
Message 7 of 18
(4,034 Views)

@Pavel_47 wrote:
Build doesn't work (if I correctly understood your suggestion)

 Well, yes, it gets rid of the broken wire. 😄 I haven't studied what you really want. As I said, do all the formatting in memory to have full control, then just write a single plain string to a file. No need for fancy highlevel IO.

0 Kudos
Message 8 of 18
(4,024 Views)

Artem.SPb a écrit :

I think this way to form array and string better.

 

When you use "insert into array" each iteration you waste memory and time


Ok, thanks.

0 Kudos
Message 9 of 18
(4,024 Views)

@Artem.SPb wrote:

 

When you use "insert into array" each iteration you waste memory and time


It's not with every iteration. Also "built array" does the same thing so there is no difference.

0 Kudos
Message 10 of 18
(3,999 Views)