Assembly Traversal, how to delete duplicates?

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.

Reply to
SW Monkey
Loading thread data ...

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

Reply to
TOP

Whats a gawk script?

Reply to
SW Monkey

Nevermind, just did some research.

Do you have a AWK script to do this?

Reply to
SW Monkey

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> > > > >

Reply to
TOP

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.