删除excel中某一列的重复项

在给图片打标签的过程中,需要提取数据集excel表中的标签。

有大量重复项,用python程序解决了这个小问题。

一、提取下表中I列中的所有菜肴标签

二、代码

二、代码

import xlrd 
def open_excel(fileName="asim.xls"):  
        try:  
            fileHandler = xlrd.open_workbook(fileName)  
            return fileHandler  
        except Exception as e:  
            print(str(e))      
 
    def scan_excel(sheet_name1=u'asim'):  
        handler = open_excel()  
        page = handler.sheet_by_name(sheet_name1)  
        return page  
 
    def trim_cols(index=8):  
        page = scan_excel()  
        col1 = page.col_values(index)  
        col2 = []  
 
        for item in col1:  
            if item not in col2:  
                col2.append(item)    
        print (col2)  
 
    def main():  
        trim_cols()  
 
    if __name__ == "__main__":  
        main()

三、标签

猜你喜欢

转载自blog.csdn.net/qq_33373858/article/details/82913446