How to delete identical lines

Discuss RoboTask here
Post Reply
marcolobaido
Posts: 70
Joined: Thu Jul 02, 2015 3:54 pm

How to delete identical lines

Post by marcolobaido »

Hi, I need to delete all the identical lines from a text file except one.
I'm able to recognize the identical lines with the "if then" command, but i don't know how to remove them. I used STR Delete, but what does "source string" stand for?

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task17"
Hide=INTEGER|0
ID=INTEGER|2123985992
LogOnAsUser=INTEGER|1
Name=STRING|"Remove duplicates"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_LOOP_SIMPLE"
Enabled=INTEGER|-1
Name=STRING|"Simple Loop"
Params=FOLDER

[Actions\Action1\Params]
begin=STRING|"1"
end=STRING|"1000"

[Actions\Action2]
ActionID=STRING|"A_TXT_EXTRACTLINE"
Enabled=INTEGER|-1
Name=STRING|"TXT Extract Line"
Params=FOLDER

[Actions\Action2\Params]
external=STRING|"1"
filename=STRING|"C:\Users\Notebook\Dropbox\Cartsan\elenco mail ditte.txt"
linecount=STRING|"0"
linenum=STRING|"{LINE_NUMBER}"
variable=STRING|"EMAIL1"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""LINE_NUMBER"" di 1"
Params=FOLDER

[Actions\Action3\Params]
incement=STRING|"1"
vaiable=STRING|"LINE_NUMBER"

[Actions\Action4]
ActionID=STRING|"A_TXT_EXTRACTLINE"
Enabled=INTEGER|-1
Name=STRING|"TXT Extract Line"
Params=FOLDER

[Actions\Action4\Params]
external=STRING|"1"
filename=STRING|"C:\Users\Notebook\Dropbox\Cartsan\elenco mail ditte.txt"
linecount=STRING|"0"
linenum=STRING|"{LINE_NUMBER}"
variable=STRING|"EMAIL2"

[Actions\Action5]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action5\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{EMAIL1}"
value2=STRING|"{EMAIL2}"

[Actions\Action6]
ActionID=STRING|"A_STR_DELETE"
Enabled=INTEGER|-1
Name=STRING|"STR Delete"
Params=FOLDER

[Actions\Action6\Params]
amount=STRING|"{StrLength{(EMAIL2})}"
from=STRING|"1"
source=STRING|"{EMAIL2}"
variable=STRING|"EMAIL_CANCELLATA"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""LINE_NUMBER"" di -1"
Params=FOLDER

[Actions\Action7\Params]
incement=STRING|"-1"
vaiable=STRING|"LINE_NUMBER"

[Actions\Action8]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action9]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
marcolobaido
Posts: 70
Joined: Thu Jul 02, 2015 3:54 pm

Re: How to delete identical lines

Post by marcolobaido »

Ok, problem solved! I used sort files and "remove duplicates" :roll:
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: How to delete identical lines

Post by Oleg »

This algorithm doesn't work.
See at the step #6
You have to remove email from source text (that is in the file: C:\Users\Notebook\Dropbox\Cartsan\elenco mail ditte.txt)

You can make this task very simple by using the action Sort Text

Also see my example below.
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task19"
Hide=INTEGER|0
ID=INTEGER|1321482429
LogOnAsUser=INTEGER|1
Name=STRING|"Remove duplicates (simple)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER

[Actions\Action1]
ActionID=STRING|"A_FILE_SORTTEXT"
Enabled=INTEGER|-1
Name=STRING|"Sort Text"
Params=FOLDER

[Actions\Action1\Params]
assignvar=STRING|"0"
case=STRING|"0"
destfile=STRING|"C:\Users\Notebook\Dropbox\Cartsan\elenco mail ditte (sorted).txt"
linecount=STRING|"0"
savetofile=STRING|"1"
sortmode=STRING|"0"
sourcefile=STRING|"C:\Users\Notebook\Dropbox\Cartsan\elenco mail ditte.txt"
sourcekind=STRING|"0"
suppress=STRING|"1"
Oleg Yershov
Post Reply