LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search for similiar string in the 2D array and display the result with different column

Solved!
Go to solution

Hi,

 

Whoever can help, I have a 2D array from txt file which have many rows and 5 column and I want to do a search and display the other column results.

 

Eg.

 

Column 0                      1                           2                                  3                           4

12345                      qwer                       asdf                            12qwe                      tjhrtyert

23568                      werr                        wef                             fgertge                     fsefff

 

 

If I manage to search 12345 and I want to display 12qwe, what should I do in labview? Please help!  

0 Kudos
Message 1 of 14
(4,588 Views)

Use the Index Array to get column 0, use the Search 1D Array to find the index element, use the index element to get the value in column 3.

 

Search Array.PNG

0 Kudos
Message 2 of 14
(4,579 Views)

Hi Dennis,

 

Thanks for your solution. I managed to display what I want. Do you know how to I write back to txt file just by replace the particular column (String).

 

Example: Column 0 and row 4: abc and Column 4 and row 4:location1 and I want to change to location4 and write it back to the text file. How am I going to do? I attached my VI (Inventory tracking)for your reference.

0 Kudos
Message 3 of 14
(4,535 Views)
Solution
Accepted by topic author LimKW

 


Example: Column 0 and row 4: abc and Column 4 and row 4:location1 and I want to change to location4 and write it back to the text file. How am I going to do? I attached my VI (Inventory tracking)for your reference.


 

I am not clear with the above sentences.also attach the file that read from the vi.Use array>>Replace array subset function to replace the elements in the array.

Message Edited by Baji on 05-27-2009 03:36 PM
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 4 of 14
(4,529 Views)

Hi Baji, the solution you provided is able to replace the array but not on the text file. I have attached the VI and txt file. Example: If i search under asset no. 0023330 and the location is ME-lab and I want to change the location to 123 and replace it on the txt file. What function should I use?

Download All
0 Kudos
Message 5 of 14
(4,506 Views)
You should store the array you are updating in a shift register.  Write the array out to the file when the for loop is done.  As you have it now in both for loops, you are always going back to work on the original array, so only the changes that happen in the last iteration of the for loops actually stick.
0 Kudos
Message 6 of 14
(4,500 Views)

Hi Raven,

 

Can u show me an example, I don't quite understand what u mean by updating in a shift register.

0 Kudos
Message 7 of 14
(4,482 Views)
Example
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 8 of 14
(4,480 Views)

Baji, thanks for arranging the block diagram, do u know how I can add a push button to activate the updated to the txt file?

0 Kudos
Message 9 of 14
(4,465 Views)
Put the same logic before u used, Put a case structure and wire a boolean control and select the file to update or not. I am not arranged ur block diagram its the cool feauture of LabVIEW 8.6 Smiley Winkit makes life easy.Now the replaced strings are updated in the file?(I am not tested)
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 10 of 14
(4,463 Views)