Assembly Traversal, how to delete duplicates?

Nov 09, 2006 4 Replies

I am using the Assembly Traversal function in my macro to go thru the current assembly, grap the Item & Description custom property, and export that into a .TXT file. If I have the same part multiple times in an assemlby or subassemlby, the part is in the TXT file multiple times.



Anyone know how I can prevent these duplicates? I am not trying to keep track of the QTY, so this isnt needed.



The easiest thing is to run a gawk script on the text file after you create it.

SW M> I am using the Assembly Traversal function in my macro to go thru the

Nevermind, just did some research.

Do you have a AWK script to do this?

Yes.

# remove duplicate, consecutive lines (emulates "uniq") awk 'a !~ $0; {a=$0}'

# remove duplicate, nonconsecutive lines awk '! a[$0]++' # most concise script awk '!($0 in a) {a[$0];print}' # most efficient script

formatting link
You would have to do some tweaking because you probably want to remove based on a field in the record. Pretty straightforward, NOT.

Another way if you have Access is to read in the text file and run a query such as

SELECT DISTINCT * FROM yourfile;

You enter this in SQL view, it is much easier than trying to figure out MSoft's way.

SW M> > > > >

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required