In python, you can find duplicate data in a column in excel and print the data after removal. 1. in python, we recommend that you use xlrd (especially read operations) for simple read/write operations in excel)
2. go to the http://pypi.python.org/pypi/xlrd to download the xlrd Library;
3. the project code is as follows:
The code is as follows:
Import xlrd
Def open_excel (fileName = "simple.xls "):
Try:
FileHandler = xlrd. open_workbook (fileName)
Return fileHandler
Except t Exception, e:
Print str (e)
Def scan_excel (sheet_name1 = u 'sheet1 '):
Handler = open_excel ()
Page = handler. sheet_by_name (sheet_name1)
Return page
Def trim_cols (index = 0 ):
Page = scan_excel ()
Col1 = page. col_values (index)
Col2 = []
For item in col1:
If item not in col2:
Col2.append (item)
Print col1
Print col2
Def main ():
Trim_cols ()
If _ name _ = "_ main __":
Main ()
Print result:
[1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]
[1.0, 2.0, 3.0, 4.0]