LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I change the value of my original data?

Solved!
Go to solution

 

if x in my txt file

Can you enter a value to change x

Simply , how do I read the position of x if the value is 5
//Not long to learning labview

 

1598170913479.jpg

1598020209432.jpg

0 Kudos
Message 1 of 4
(633 Views)

In future can you post the actual VI rather than pcitures. It makes it easier to debug and make changes to demonstrate how to do stuff. I have had to recreate your example here (I only did it because it was small). Also, if your example needs data to run post that as well.

 

Multiple ways of doing this, this is one of them. Depending upon your actual application this may not be appropriate but it works. this replaces x with 999.

string.png

 

Warning, I suspect this will be quite a slow function if you have large files, especially if you select replace all/ slash your 'x' is at the end of the file.

0 Kudos
Message 2 of 4
(611 Views)

 Thanks for your response

I ran your program

But what I want is that the original data (txt file) will also change

I didn't make it clear here, sorry

My next experiment is to update a value every 30 seconds and store it in the position of x


In the attached file, there is an x ​​in line H01

 

0 Kudos
Message 3 of 4
(593 Views)
Solution
Accepted by topic author luosser

Even with your attached file and explanation, it took me looking at the entire file to figure out what you meant!  When I saw "H01", I thought you were referring to a "Cell Address", line 1, column H, but there were only 7 columns.  Maybe you meant a line with "x" in the first column?  No, that didn't make sense.  But then I saw in Line 55, column 4 had "x" in it, and now I understand what you want to do.

 

Forget LabVIEW for a moment.  Assume I hand you a printout of your text file, and say "rewrite this Text file, replacing "x" with the number I tell you".  How would you do this (assuming you start with a Text file on disk)?

 

Here's one way:

  1. Open the Text file and read all of the data into "something".
  2. Find "x".
  3. Replace "x" with the number you wish to store.
  4. Save the modified Text file (with the same, or a different, name).

Now, there are some details you might want to consider.  One is the format of the text file.  It is text, and more specifically, it is lines of text.  It has what looks like "columns" separated by commas.  For most (but not all) of the lines, the first comma-delimited entry consists of a Capital Letter and a 2-digit number -- is this a known, fixed pattern?  For almost all of the other entries, the data consist of a comma-delimited string that seems to represent a decimal (floating-point) number with 3 digits of precision, the exception being the line containing the "x" (which, of course, has a string representation).

 

So now think about how you might use LabVIEW functions to carry out your task.  If you don't know much about LabVIEW File I/O, go look at the Tutorial Material listed on the first page of this Forum.  If you don't know much about Numbers and Strings, use the Tutorials.

 

Try doing this yourself.  You will learn much faster this way, and it will "stick" with you longer.  The only best way to learn to write programs is to Write Programs.

 

Bob Schor

0 Kudos
Message 4 of 4
(551 Views)