LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I first clear data then save to a file

Solved!
Go to solution

Hi Reduanul,

 


@REDUANUL wrote:

But want to append new data to an already existing file by "deleting" the old content and only write the new data to the existing file.


So this is what your code should do - and actually is doing!

 

By "replace or create" you are "deleting the old content" of the file and then you "only write the new data" into the "existing file"…

(As has been said before you don't need to "set to end of file" after recreating the file.)

Best regards,
GerdW


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

@REDUANUL wrote:

Hello GerdW,

 

Here is my explanation:

 

I have created a file as of now. But want to append new data to an already existing file by "deleting" the old content and only write the new data to the existing file.

 

I hope now it's clear.

 

 


Sorry, but that is not clear and does not make sense.

 

If you delete the old content, then you can't append because there is now nothing to append to!  Append means to put something at the end of something that already exists!

0 Kudos
Message 12 of 16
(2,038 Views)

please enlighten us with how the file content looks like before and after your said "append" operation?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 13 of 16
(2,029 Views)

Hello RavensFan and Santo,

 

Well, let me try again to explain my problem: 

 

The problem is I am trying to save XY graph data in a .txt file. So when the first time I save my data, everything is fine, and a new file has been created. Later on, when I am saving again, new data is being saved (replacing the file) with old data. I want each time only new data will be saved, so there should not be old data.

 

Now here is my code:

 

aaaaa.png

 

Here whatever is happening after saving my data:

 

aa.png

 

Thanks for your time.

0 Kudos
Message 14 of 16
(1,989 Views)
Solution
Accepted by topic author REDUANUL

I downloaded your VI snippet and dropped it into a blank VI.

 

I had to change the browse options for the application directory so that it would select folders. Right now it is set for files.  (Though that might be an artifact of the snippet making and dropping process.)

 

I ran your VI.  Once with one string, and again with anotherl

 

It DOES NOT do what you describe.  After the first run, it only had the first string.  After the second run, it only  had the second string.

 

You must have something going on in code besides what you have presented in this last e-mail.

Message 15 of 16
(1,986 Views)

RavensFan got the problem.

 

You were right. "You must have something going on in code".

 

Now everything is solved by adding an empty string (in my code) for each saving operation. Now only new data remains, and while loading, it's plotting with new data instead of old data and new data.

 

Appreciate your effort and suggestions 🙂

 

 

 

0 Kudos
Message 16 of 16
(1,973 Views)