Showing results for 
Search instead for 
Did you mean: 

Adding data to text file

Go to solution

Hello All,

I am still fairly new to LabVIEW. This VI was not built by me but by someone who had left our company so now i get to solve its problems with no help or notes! Anyways this VI takes Data from our Atlas Copco and adds it into a text file. So far that part works fine but the problem that i am trying to fix is that every time it saves the data it duplicates data that has already been added to the text file. I need this program to only save the new data from the AC. We have another Vi that goes through the text data to see if there were any serial numbers that had been skipped or are out of tolerance. Since there is duplicated data in the text file, the program gets confused and states that all serial numbers are missing. Any ideas on how i can go about this problem?

0 Kudos
Message 1 of 8

I added a Zip of the whole Project since i don't think opening my VI will work unless the other VI's are added.


The program i am having trouble with is in the "1305 Rev 4 info" and its the "MAIN - AUTO Tightening Data Export to TXT -"

0 Kudos
Message 2 of 8

You are missing the subVI's.  I don't see any file handling in the main VI, so perhaps it is happening in a subVI.


Okay, you have since added a zip file.  I'd highly recommend building a project file for this project.


My guess, somewhere there is a continually growing string in a shift register that is being appended to the text file on every iteration.

I do see in the subVI Data File Location, it opens the text file and moves the pointer to the end and writes whatever data is in that array.  But I don't understand what the overall flow of your program is supposed to be.  It seems to be based on an integer that is either 0, 10, 20, 30 integer.  (What is this line number basic programming?


Meaningful names placed in a typedef enum would be helpful here.  So not knowing what the overall flowchart of this program looks like, but whatever happens, when it gets to case "30", data is getting appended to the end of a text file.

Message 3 of 8

I believe the file handling subVi that you are referring to is under the "Write to txt File -" Unless you are talking about something else....

0 Kudos
Message 4 of 8

This project is built in a project file. I might have sent it incorrectly :/. But i believe the mindset of our Engineer was to use those integers as a way of progressing through each case structure. Whatever case structure number that is outside of the loop will indicate which case structure to start on. 

I understand that the data is being appended to the end of the text file. But is there a way to add some sort of check vi that looks at the txt file first and compares it to the new data being added and then eliminating what has already been added?

0 Kudos
Message 5 of 8

@DerekKEB wrote:

I believe the file handling subVi that you are referring to is under the "Write to txt File -" Unless you are talking about something else....

Correct.  And in that is a subVI called Data File Location that opens the file for you and sets the file position to the end.

0 Kudos
Message 6 of 8
Accepted by topic author DerekKEB

Is there a way in LabVIEW to create a Vi that looks through a text file and delete duplicated data? Because right now data is being appended to the text file per every time we run the VI.

0 Kudos
Message 7 of 8

Sure.  You can program a VI to do that.


Or the better solution is that you can work on the logic of your current program to only append new data and not all of the data.

Message 8 of 8