网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 电脑运用 > Office
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 153.99.40.76
Old 2015-08-09, 12:31 PM
Nada Nada is offline
初级会员
 
Join Date: 2012-12-19
Posts: 1
Nada 现在声名狼藉
Default 使用EditPlus和批处理删除文本重复内容行

由于要处理一个两万多行的数据,但要删除其中内容重复的行,所以找了几个方法:

1、使用EditPlus-工具-排序,勾选“删除重复”。可惜不想把内容排序,却被自动排序了。(勾选”区分位置”,好像没用?),这个效率相当快~差不多是瞬间完成的,之所以没放弃editplus,确实它的优点有很多。



2、用sed替换重复内容,使用命令 -n “G;s/\n/&&/;/^\(.*\n\).*\n\1/d; s/\n//;h;P” “$(FilePath)” (这里是在editplus里的使用,注意$(FilePath)必须是带路径的文件名)。当然sed不需依赖editplus,可以单独使用的。优点:删除重复内容后,顺序结构不变。缺点:不支持UTF-8,处理大文件时(2w多行)就不行了。

3.使用一个批处理

@echo off
:: 删除重复的行,但不能保留空行
:: 对不符合变量命名规则、变量个数超过限制的文本都无法正确处理
(echo 清除重复行后的文件内容:& echo.)>str_.txt
for /f “delims=” %%i in (testText.txt) do (
if not defined %%i set %%i=A & echo %%i>>str_.txt)
:: start str_.txt

当然也不支持utf8,效率也比较慢,处理2w多行用了1分多钟,不过排序没有改变
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 09:19 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.