Re: What is Best Method To Determine Duplicate Items in a Large List?
Re: What is Best Method To Determine Duplicate Items in a Large List?
- Subject: Re: What is Best Method To Determine Duplicate Items in a Large List?
- From: Jim Weisbin <email@hidden>
- Date: Mon, 6 Nov 2017 08:40:27 -0500
On Nov 4, 2017, at 6:23 AM, Shane Stanley <email@hidden
<mailto:email@hidden>> wrote
>>
>
> So we'll wait for to you get to the email where Jim added:
>
>> I should have been more specific.
>> I need to identify the index numbers of the dup items
>
Here’s another solution. I haven’t tested this on a large file, so I don’t know
how the speed compares to ASObjC:
set theFile to quoted form of (POSIX path of (((path to desktop folder) &
"test_list.txt") as text))
set theCmd to "from __future__ import with_statement\nwith open(" & theFile &
", 'r') as f:\n mylist = f.read().splitlines()\nfor i in set(mylist):\n
if mylist.count(i) > 1:\n print(i, mylist.index(i))"
set theRslt to do shell script "python -c " & quoted form of theCmd
display dialog theRslt
Indexes start from zero, the index of the first duplicated item is listed, the
files is assumed to be named test_list.txt on the desktop
Jim Weisbin | C.T.O. | Human | Post Human | 27 West 20th Street | Suite 801 |
New York, NY | 10011 | (212) 352-0211 | (917) 375-2272 | 2046 Broadway |
Santa Monica, CA | 90404 | (310) 264-0211 telephone | www.humanworldwide.com
<http://www.humanworldwide.com/>
Click here <http://www.humanworldwide.com/#commercials> to view our online reel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden