I am trying to delete duplicates but the job just finishes with an exit code 0
tysondogerz at gmail.com
tysondogerz at gmail.com
Tue Nov 7 02:18:18 EST 2017
I am trying to delete duplicates but the job just finishes with an exit code 0 and does not delete any duplicates.
The duplicates for the data always exist in Column F and I am desiring to delete the entire row B-I
Any ideas?
import openpyxl
wb1 = openpyxl.load_workbook('C:/dwad/SWWA.xlsx')
ws1 = wb1.active # keep naming convention consistent
values = []
for i in range(2,ws1.max_row+1):
if ws1.cell(row=i,column=1).value in values:
#pass
#else:
values.append(ws1.cell(row=i,column=1).value)
for value in values:
ws1.append([value])
I have attempted to do this with openpyxl for an excel as well as other methods (including csv though this deleted rows excessively).
CSV:
with open('1.csv','r') as in_file, open('2.csv','w') as out_file:
seen = set() # set for fast O(1) amortized lookup
for line in in_file:
if line not in seen:
seen.add(line)
out_file.write(line)
More information about the Python-list
mailing list