LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

data to text file with header

Solved!
Go to solution

Hello,

 

for my test application i want to store the test data into a text file with header. This should be like this:

 

name, serial, count, min. current, max. current

Mister Smith

1234567890

111

10

1000

data:

1 345 34

2 355 23

3 360 34

...

 

The first row are only informations about the headers rows. "data:" is the start marker of the data. The data consists  of a number, the mean value of current an the test time in s.

 

Now i write an string array to the text file, but if the length of the header change i overwrite the data. For example the name is Mister John Smith.

 

In my program i can create a new file with header and i can change the header later. In the measurement routine i put the data into the file.

 

How can I solve this?

 

thankyou

 

schwede

0 Kudos
Message 1 of 6
(3,215 Views)

Hi Schwede,

 

the easiest would be to disallow changing the header after start of the measurement. (That's reasonable, don't you think so?)

 

The next best option is to use a fixed-sized header - easiest when you need to change the header later on.

 

A 3rd option is to reload the whole file, change the header and write the whole file again - there is no "insertion" possible for files...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(3,207 Views)

Hello,

 

"The next best option is to use a fixed-sized header - easiest when you need to change the header later on."

 

How can I do this?

 

 

0 Kudos
Message 3 of 6
(3,202 Views)

Hi Schwede,

 

by writing a fixed-sized string? (fill up with spaces, empty lines, tabs, #, whatever you like Smiley Wink )

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(3,198 Views)

I think the constant Header size is good, but i can`t made it.

Have you an example for me please?

0 Kudos
Message 5 of 6
(3,183 Views)
Solution
Accepted by Schwede

Hallo Schwede,

 

here's an example:

sizelimit.png

Be carefule and make some checks, at the moment it will cut "your input" when it exceeds 512 bytes...

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 6
(3,176 Views)