top of page

You can use the below python script to find where there are duplicates in a character set.


First open a Python IDLE shell window and enter this code:


>>> def find_duplicates(s):

elements = {}

for char in s:

if elements.get(char,None) != None:

elements[char]+=1

else:

elements[char] = 1

return [k for k,v in elements.items() if v>1]


Then enter the set of characters you want to search using the print command and the command created by this code

>>> print(find_duplicates("ATRZSWAPOS"))


After this is saved, Python will give you the result shown below.





You can use the replace command in python to replace a string for a set number of occurrences in which it appears in a set.

Designate a set using a letter and enter strings for the set between quotes.

>>> z = "InfoGov Identification Preservation Collection Processing Review Analysis Production Presentation"

Use the replace command, preceded by the designation for the set to indicate the terms you to find and replace:

>>> z = z.replace("Review","Litigation Support")

Output the result >>> print(z)

In order to replace only X number of occurrences of a string (starting from the beginning at the left) . . .

>>> x = "Volume Volume Set Set Folder Volume Folder File File Volume"

Modify the replace command by listing a number at the end of the values in parentheses: >>> x = x.replace("Volume","PRODUCTION",3) >>> print(x)

In this example only the first three instances of 'Volume' are replaced.



After you have installed Python on a Windows operating system, you can start the Python interpreter by entering Windows command prompt and entering the command 'py'

In this interactive mode you will be able execute Python statements. In this example, we direct a string of text to be printed three times with a line break at the end each time, by appending the \n line break command in single parentheses added to the end with a plus sign.

In order to exit the interactive mode press CTRL + Z, and then press enter.


Sean O'Shea has more than 20 years of experience in the litigation support field with major law firms in New York and San Francisco.   He is an ACEDS Certified eDiscovery Specialist and a Relativity Certified Administrator.

The views expressed in this blog are those of the owner and do not reflect the views or opinions of the owner’s employer.

If you have a question or comment about this blog, please make a submission using the form to the right. 

Your details were sent successfully!

© 2015 by Sean O'Shea . Proudly created with Wix.com

bottom of page