I write because I am developing a script to screen repeated records in an excel with openpyxl. The script is as follows:
import openpyxl as xl def main (file): wb = xl.load_workbook (file) sh = wb.active store =  for and in range (1, 1 + sh.max_row): store.append (sh["B" + str(e)].value) many =  for and in store: if many.count (e) <1 < store.count(e): many.append(e) for e in range(1, 1 + sh.max_row): count = 0 if many.count(sh["B" + str(e)].value) > 0 and count> 0: sh["J" + str(e)].value = "N" elif many.count (sh["B" + str(e)].value)> 0: count + = 1 wb.save (file.replace (".xlsx", "_act.xlsx"))
What it does is: take all the possible values in column B, see which ones are repeated (that is, they are present more than once) and separate them (it does so in a separate list, hence the A <1 <B , since I want the count of the same in the separate list to be less than 1 and that the count in the list of records be greater than 1). Once you have the separate list, look at record to record in column B if it is present in the repeated list. If it is and is not the first instance of it, mark it in column J with an "N" to be able to separate it via excel later.
The fact is that, as I execute it, it returns a copy of the original (and I know it is a copy because I know that there are repeated records in column B.
Thanks in advance