LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delete duplicated data from text file

Hi to all expert ,
 
i have a text file with the folling data:
 
    0001000000       PASS        19-06-2005    17:03:04   
    0001000001       PASS        21-06-2005    17:05:12   
    0001000002       PASS        21-06-2005    17:09:02   
    0001000000       FAIL          21-06-2005    17:11:03   
    0001000003       PASS        21-06-2005    17:13:03   
    0001000004       PASS        21-06-2005    17:15:05   
    0001000003       FAIL           21-06-2005    17:17:04   
    0001000000       FAIL           21-06-2005    17:19:05   
    0001000000       FAIL         23-06-2005      17:21:08  
 
 
as you can see there is a duplicated data. i want do delete all duplicated data by checking the date and time and live the last one that was checked.  after that  it's need to do short by the id number.
for example: on this data file above
 
 
    0001000000      FAIL         23-06-2005      17:21:08
    0001000001      PASS       21-06-2005      17:05:12
    0001000002      PASS       21-06-2005       17:09:02
    0001000003      FAIL          21-06-2005       17:17:04
    0001000004      PASS       21-06-2005        17:15:05
 
any HELP?...
regards,
eyal.
 
0 Kudos
Message 1 of 10
(4,228 Views)
First, if you are creating the file, you should think about doing this while you're getting your data, before writing to the file.
 
If you want to handle the file, you should start by reading it as a text spreadsheet. You can modify the Read from spreadsheet VI to read text files by double clicking it and following the instructions on its diagram.
 
I assume the lines are sorted by date and time. If they're not, this can also be taken care of.
 
You should now have a 2D string array 4 columns wide. Wire it into a for loop and create a shift register with an empty 2D string array wired into it. This will be your new array. The first column will be the reference array. Use Index Array to get the number of each element and search the reference array (use index array with 0 wired into the column input to get it) for that number. If you get -1, Insert the entire row into the new array. If you get another number, Replace that row in the new array with the current row.
 
Sorting by the first column can be done basically in the same way - create a 2D array the size of your new array and wire it into a shift register in a new for loop. Do a Sort 1D Array on the first column of the new array and wire it into the for loop. Use search 1D array to find where each sorted element was in the original array and use Replace Array Subset to replace it.
 
Now, save the 2D array back into the file.

___________________
Try to take over the world!
0 Kudos
Message 2 of 10
(4,219 Views)
Hello.
Here is an example

You could add error checking to this code.

Message Edited by EVS on 08-26-2005 05:53 PM


Jack
Win XP
LabVIEW 6.1, 7.0, 7.1, LabWindows/ CVI 7.1
Let us speek Russian 🙂
Download All
0 Kudos
Message 3 of 10
(4,220 Views)

Hi EVS,

I have labview 7.0 and i cant open the files,

can seand this for labview 7.0?

regards,

eyal.

0 Kudos
Message 4 of 10
(4,201 Views)
Sure. Here it is.

Jack
Win XP
LabVIEW 6.1, 7.0, 7.1, LabWindows/ CVI 7.1
Let us speek Russian 🙂
0 Kudos
Message 5 of 10
(4,196 Views)
Hi, evs
thank's i owen you a beer.
 
regards,
eyal.
0 Kudos
Message 6 of 10
(4,194 Views)
🙂
 
Welcome to Moscow, Russia.
 
The "Remove duplicates" VI  is a part of OpenG packet. You may find much more information on http://www.openg.org.
 

Jack
Win XP
LabVIEW 6.1, 7.0, 7.1, LabWindows/ CVI 7.1
Let us speek Russian 🙂
0 Kudos
Message 7 of 10
(4,192 Views)

i will look there for more info to my project .

thank's again and SPA-CIVA.

regards,

eyal.

0 Kudos
Message 8 of 10
(4,185 Views)

I suggest that you do have a look at my solution, because it's much cleaner and simpler to change if you have more columns. Also, it avoids the (probably very minor in this case) overhead of dealing with clusters (except in the OpenG Sort 2D array).

In this case, I did the conversions from string to array and back inside the VI, but it is recommended that you have a copy which handles strings arrays as described in my last post.


___________________
Try to take over the world!
0 Kudos
Message 9 of 10
(4,167 Views)
DF, tst
 
thank's for your solution i'll will cheack it.
 
regards,
eyal.
0 Kudos
Message 10 of 10
(4,164 Views)