DonationCoder.com Software > Finished Programs
DONE: Delete double lines (all but the first) in a text file
jgpaiva:
Install MinGW or alike : DevCPP does this for you excellently...-Gerome (March 16, 2006, 02:41 PM)
--- End quote ---
That's good, i'll give it a go next time I need to compile C. But by now, and for the next 4 months, I only see Lisp, Pov-Ray, VRML and Java ;)
Maybe next semester. But thanks by the pointer, it'll surelly be useful!!
jgpaiva:
Ok, now i got around to updating this script.
The blank lines bug is fixed, and the msgbox also is right. I think it's now as you requested, TW ;)
.exe version
.ahk version
TWmailrec:
To jgpaiva Charter Member, RepeatedEntries.ahk
Re: DONE: Delete double lines (all but the first) in a text file
Program is now perfect!
(I added back in the %1% check for drag
and drop and command line parameter.)
Many thanks
TW
lanux128:
jgpaiva & TWmailrec:
i liked your script very much that i had modified it a bit for my own usage & added a gui...
but i not too clear on why both of your scripts differ... e.g. jgpaiva's script adds a linefeed to the end of every line while TWmailrec's deletes all empty lines. is this on purpose?
in any case, here's the code & screenshot of the gui.
the modified code; Date: Apr. 03, 2006
#Persistent
#SingleInstance force
SetBatchLines,-1
Title=Delete Duplicate Lines
GoSub, ShowMain
Return
ShowMain:
Gui, -SysMenu +MinimizeBox
Gui, Add, GroupBox, x6 y6 w360 h172, %Title%
Gui, Font, s8 CDefault, Tahoma
Gui, Add, Text, x16 y25 w180 h20, Original File:
Gui, Add, Button, x326 y45 w30 h20 gSelectFile, ...
If File =
Gui, Add, Edit, x16 y45 w300 h20 readonly vFile,
Else
GuiControl,, File, %file%
;---0---
Gui, Add, Text, x16 y80 w180 h20, Output File: ;Must not be the same...
If FileOut =
Gui, Add, Edit, x16 y100 w300 h20 readonly vFileOut,
Else
GuiControl,, FileOut, %FileOut%
Gui, Add, Button, x100 y140 w75 h25 gProcess, Process
Gui, Add, Button, x200 y140 w75 h25, Quit
Gui, Show, x270 y110 h185 w375, %Title%
Return
SelectFile:
FileSelectFile, File, 1, %A_MyDocuments%, Select text-file for processing, Text Files (*.csv; *.txt)
If File = ;user presses Cancel...
Return
GuiControl,, File, %file%
SplitPath, File,CurFile,CurFolder,CurExt,CurFileNoExt,
FileOut=%CurFolder%\%CurFileNoExt%_after.%CurExt%
GuiControl,, FileOut, %FileOut%
Return
Process:
If File =
Return
FileToRead=%File%
filetowrite=%FileOut%
;To add check-box option, to overwrite existing output file?
;IfExist,%filetowrite%
; {
; FileDelete,%filetowrite%
; }
FileRead,CompleteFile,%FileToRead%
StringSplit,index,CompleteFile,`r`n,`r`n
found=
count:=index0
count2:=count
GoSub,CreateGui2
ProgressFlag:=false
loop,%count%
{
GuiControl,2:,bar,%A_Index%
If ProgressFlag
break
position:=A_Index
Word:=index%position%
If word is space
{
FileAppend,%word%`n,%filetowrite%
continue
}
IfInString,found,%Word%
continue
count2-=1
loop, %count2%
{
position2:=position+a_index
Word2:=index%position2%
if Word=%word2%
found=%found% %Word% ,
}
Fileappend,%Word%`n,%filetowrite%
}
if found=
{
Msgbox,, %Title%, No duplicate lines were found.
GoSub, 2GuiEscape
}
else
{
StringTrimRight,found2,found,2
Msgbox,, %Title%, The following strings were repeated: %found2%
GoSub, 2GuiEscape
}
Return
CreateGui2:
Gui, 2:Add,Text,,Now checking for duplicate entries. Press esc to skip.
Gui, 2:Add, Progress,vbar w300 h20 -smooth Range0-%count%,
Gui, 2:Show, ,%Title%
Return
2GuiClose:
GoSub, ShowMain
;exitapp
2GuiEscape:
Gui, 2:destroy
ProgressFlag:=true
GoSub, ShowMain
Return
ButtonQuit:
GuiEscape:
GuiClose:
ExitApp
DONE: Delete double lines (all but the first) in a text file
jgpaiva:
jgpaiva & TWmailrec:
i liked your script very much that i had modified it a bit for my own usage & added a gui...
but i not too clear on why both of your scripts differ... e.g. jgpaiva's script adds a linefeed to the end of every line while TWmailrec's deletes all empty lines. is this on purpose?
-lanux128 (April 05, 2006, 12:37 AM)
--- End quote ---
TW's script is the same i made before, but with a few modifications he introduced to suit him better. My latest script doesn't remove blank lines because TW asked me for it not to remove them ;)
But now, the script works well for you, right? :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version