This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 编程问题:如何在一个文本文件(如Txt)中,比较n行字符, 删除重复的字符串行,请见示例:This is a test.
This is a test.
This is another test.
This is another test.
This is another test.
删除其中重复的内容,变成:
This is a test.
This is another test.
谢谢指点!
-oxford(candy);
2002-10-16
{185}
(#800849@0)
-
uinx下应UNIQ就能解决,看看uniq的用法吧,man uniq.
-easyway(翠花,回家吧!);
2002-10-16
(#800864@0)
-
好象没什么难的.对每一行比较以前行是否出现过即可. 是则删除, 否则保留.
-taop(〓遥想当年青衫薄〓);
2002-10-16
{53}
(#800870@0)
-
用正则表达式
-guestagain(guest again);
2002-10-16
(#800874@0)
-
要交作业了
-mememe(me);
2002-10-16
(#800876@0)
-
嵌套循环
-x86(爱谁谁);
2002-10-16
(#800917@0)
-
sort in.txt | uniq > out.txt
-xiagangle(xiagangle);
2002-10-16
(#800938@0)
-
我没有unix, 是Windows/Dos, 用什么语句,能够一行一行的读,然后一行一行的比较?下个星期交作业,不知能不能详诉,先谢过了
-oxford(candy);
2002-10-16
(#801059@0)
-
用什么语言啊
-hugefox(长得象熊的狐狸);
2002-10-16
(#801238@0)
-
upup
-oxford(candy);
2002-10-16
(#801229@0)
-
你一年学费多少钱?现在行情一般来说1/12×cost of each course=一次assignment收费,或者50块,取多的。舍不得就好好看书去。这儿没人帮你做作业。
-mememe(me);
2002-10-16
(#801250@0)
-
你不乐意帮忙就拉倒,上Rolia就是来相互帮助的,你没有念过书吧?从来没有请教过你的同学?
-oxford(candy);
2002-10-16
(#801299@0)
-
没兴趣和你吵架,从你问的“我没有unix, 是Windows/Dos, 用什么语句,能够一行一行的读,然后一行一行的比较?”就知道开学到现在没听过课。不就是想弄个现成代码,我帮你up。
-mememe(me);
2002-10-16
(#801336@0)
-
有同感,而且又不说用什么语言,想帮也帮不了。
-guestagain(guest again);
2002-10-16
(#801343@0)
-
用lilyba(Sunshine)的,SUN+Oracle应该就可以搞定。
-mememe(me);
2002-10-16
(#801356@0)
-
天哪!!!现在硬件是好了,就这点事也不用这么折腾吧!
-guestagain(guest again);
2002-10-16
(#801365@0)
-
hehe,我最讨厌写循环了。
-lilyba(Sunshine);
2002-10-16
(#801374@0)
-
于是要动用数据库。
-guestagain(guest again);
2002-10-16
(#801383@0)
-
我老用数据库。所以,一想就是这一套。
-lilyba(Sunshine);
2002-10-16
(#801390@0)
-
呵呵,你厉害。
-guestagain(guest again);
2002-10-16
(#801395@0)
-
access, sql server都可以。
-lilyba(Sunshine);
2002-10-16
(#801370@0)
-
你不如说我雇个人一行一行删算了。
-guestagain(guest again);
2002-10-16
(#801373@0)
-
发扬3个代表,向高标准看齐!
-mememe(me);
2002-10-16
(#801376@0)
-
那就选AS/400+ORACLE WAREHOUSE+VIUALAGE FOR JAVA?
-easyway(翠花,回家吧!);
2002-10-16
(#801392@0)
-
HP的成吗?用了好几年了,比较顺手的说。
-mememe(me);
2002-10-16
(#801404@0)
-
详细解答见内If (you are femal) && (under 30 ) Then
company me to bar in this saturday night;
While ( talking, touching, ....);
you can get your answer
else
you have to do it by yourself
end
-chengdunese(憨憨);
2002-10-16
{190}
(#801296@0)
-
good good. How did you know candy is a MM
-shipcaptain(社员都是向阳花);
2002-10-16
(#801307@0)
-
revise:If (you.getSex()) && (you.getAge() < 30 ) {
me.ask_companymetobar(time.SATURDAYNIGHT);
While ( happytime.expire() ) {
we.talking();
we.touching();
happytime.deduct();
}
you.getAnswer ();
} else {
you.do_it_by_yourself();
}
-easyway(翠花,回家吧!);
2002-10-16
{267}
(#801328@0)
-
还是翠花想的周全
-chengdunese(憨憨);
2002-10-16
(#801347@0)
-
Professional
-multilin(multilin);
2002-10-16
(#801350@0)
-
If (you.getSex()) && (you.getAge() < 30 )?
-guestagain(guest again);
2002-10-16
(#801358@0)
-
bug,haha
-easyway(翠花,回家吧!);
2002-10-16
(#801371@0)
-
If (you.getSex(sex.female)) && (you.getAge() < 30) && ( you.getAge() > 16)
大家那的法还是要守的。
-chengdunese(憨憨);
2002-10-16
(#801396@0)
-
嗬嗬,写程序泡妹妹?嗯,妹妹逻辑思维不好,全乱了。
-lilyba(Sunshine);
2002-10-16
(#801402@0)
-
面向对象编程法则:找准对象才下手,否则肯定乱。
-easyway(翠花,回家吧!);
2002-10-16
(#801412@0)
-
语法呀语法,同志。
-guestagain(guest again);
2002-10-16
(#801406@0)
-
While ( ! happytime.expire())
-dibert(呆伯);
2002-10-16
(#801409@0)
-
高! 请也参考我的!aa = readln(text);
bb = readln(text);
if (aa = bb) and ( "you are MM" ) and ( " you invite me dinner" )
then
print ( " let's go! " )
else
exit
-zyl_prc(George);
2002-10-16
{158}
(#801424@0)
-
:-)post your answer
if answer is right
If (you are smart & hot & cool) && (under 30 ) Then
company me to bar this saturday night;
endif
else
you have to do it by yourself
endif
-lilyba(Sunshine);
2002-10-16
{212}
(#801460@0)
-
Your statements are not correct. " If (you are femal) && (under 30 ) " but while(false), what is the result?
-ilikeit(I like it);
2002-10-17
(#802263@0)
-
不知道你用什么语言,原理只能就是这样了while (not eof (sourcefile))
set flag=0
readline(sourcefile) into tmpline
while( not eof(destinefile))
readline(destinefile) into tmp1line
if tmpline=tmp1line then
set flag=1
exit while
end if
move the cursor to the next line
end while
if flag=0 then
writeline(tmpline) into destinefile
end if
move the cursor to the next line
end while
-oceandeep(北极熊® Zzz Zzz);
2002-10-16
{490}
(#801329@0)
-
我的办法:1生成数据文件,一个表中的一个字段,每行文字作为不同纪录。2用sql,select distinct搞定。
-lilyba(Sunshine);
2002-10-16
(#801340@0)
-
use PERL, it only needs 4 lines. PERL is the most powerful language handling text file. ( Code inside )
-hillman(山大王);
2002-10-16
{569}
(#801413@0)
-
I tested your code. It is perfect. Do you know where the perl is used mostly?
-multilin(multilin);
2002-10-17
(#801620@0)
-
我的办法是:把内容放入数组中,然后取出来比较,相同的话删除。
-kk629(kk);
2002-10-17
(#801650@0)
-
高手指点,本人初学JAVA
-pants(花和尚叔叔);
2002-10-17
{1535}
(#801700@0)
-
I am not a programmer, just a system analyst. I am not good at java, but there are 3 obvious errors in your code.1
strTemp = rafFile.readLine();
should be move out of the for loop.
2.
after
for (int i=0; i<lineString.length(); i++)
you don't need to [i+1]. because i is already the last item in the array
---> if (!found) {lineString[i+1] = strTemp.toString();
3
It seems you try to use a 'single loop' to do a 'double loops' job
it is impossible.
BTW double loop is very inefficient if the file is big
Cheers
-hillman(山大王);
2002-10-17
{427}
(#801741@0)
-
Thanks a lot! But my big problem is : it doesn't work at all! Hahahahaha......
-pants(花和尚叔叔);
2002-10-17
{1520}
(#801755@0)
-
up!
-pants(花和尚叔叔);
2002-10-17
(#801962@0)
-
using Perlopen (IN, "input.txt");
open (OUT, ">output.txt");
my $line = "";
while (<IN>)
{
s/^\s+//g;
if ("$line" ne $_)
{
$line = $_;
print OUT "$line";
}
}
close (OUT);
close (IN);
-sabotage(不会游泳的鱼);
2002-10-17
{243}
(#803171@0)