excel文件去重

#导入pandas
import pandas as pd
#1.读取excel中的数据;
frame = pd.DataFrame(pd.read_excel('C:/Users/EFY/Desktop/11/数据.xls', 'Sheet1'))
#2.去除重复行后的数据;
data = frame.drop_duplicates(subset='sn', keep='first', inplace=False)
#drop_duplicates用法:
#subset=‘需要去重复的列名’, keep=‘遇到重复的时保留第一个还是保留最后一个’, inplace=‘去除重复项,还是保留重复项的副本’
#3.保存去重后的数据到excel;
data.to_excel('C:/Users/EFY/Desktop/11/处理后的数据.xls', encoding='gbk')
#或者
#data.to_csv('C:/Users/EFY/Desktop/11/处理后的数据.csv', encoding='utf8')

----------------------------------


# 二、将testdata.txt文件提取至csv文件
# 1、要求:①表格第一列:文件中IP,②表格第二列:文件中Serial Number;③表格第三列:文件中mobile

#打开testdata
r = open('testdata.txt',mode='r')
#打开需要写入的csv
f = open('testdata.csv',mode='a+')
# 逐行读取testdata
line = r.readline()
# 判断当前是否是可以处理的行
    # 是
    # 当前这行内容用‘,’分隔开将 三列信息写进去
     # 然后读取下一行
    # 否,不执行写入
while (line):
    if 'out' in line:
        f.write(line.replace('[','').replace('] out:     Serial Number: ', ',').replace('  mobile: ',','))
    line = r.readline()

 

FDUPES 是一个文件工具,可在指定的文件夹中标识出复的文件。 使用方法: Usage: fdupes [options] DIRECTORY...  -r --recurse       for every directory given follow subdirectories                     encountered within  -R --recurse:      for each directory given after this option follow                     subdirectories encountered within  -s --symlinks      follow symlinks  -H --hardlinks     normally, when two or more files point to the same                     disk area they are treated as non-duplicates; this                     option will change this behavior  -n --noempty       exclude zero-length files from consideration  -f --omitfirst     omit the first file in each set of matches  -1 --sameline      list each set of matches on a single line  -S --size          show size of duplicate files  -q --quiet         hide progress indicator  -d --delete        prompt user for files to preserve and delete all                     others; important: under particular circumstances,                     data may be lost when using this option together                     with -s or --symlinks, or when specifying a                     particular directory more than once; refer to the                     fdupes documentation for additional information  -v --version       display fdupes version  -h --help          display this help message 标签:FDUPES
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值