Discuss RoboTask here
DK.Ideagen
Posts: 22 Joined: Wed Mar 09, 2022 10:33 pm
Post
by DK.Ideagen » Wed Apr 27, 2022 4:13 pm
I found the following task on this form for turning CSV values into variables.
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task318"
Hide=INTEGER|0
ID=INTEGER|2024929902
LogOnAsUser=INTEGER|1
Name=STRING|"CSV to variables"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER
[Actions\Action1]
ActionID=STRING|"A_DIALOG_OPEN"
Enabled=INTEGER|-1
Name=STRING|"Open Dialog"
Params=FOLDER
[Actions\Action1\Params]
allowseveral=STRING|"0"
caption=STRING|"Open File"
default=STRING|"None"
filter=STRING|"*.csv"
stopifcancel=STRING|"1"
variable=STRING|"SOURCE"
[Actions\Action10]
ActionID=STRING|"A_LOOP_SIMPLE"
Enabled=INTEGER|-1
Name=STRING|"Simple Loop"
Params=FOLDER
[Actions\Action10\Params]
begin=STRING|"1"
end=STRING|"{sz}"
variable=STRING|"NUM"
[Actions\Action11]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action11\Params]
message=STRING|"var{num} = {var{num}}"
type=STRING|"3"
[Actions\Action12]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
[Actions\Action2]
ActionID=STRING|"A_READ_TXTFILE"
Enabled=INTEGER|-1
Name=STRING|"Read Text File ""{SOURCE}"" (65001)"
Params=FOLDER
[Actions\Action2\Params]
codepage=STRING|"65001"
filename=STRING|"{SOURCE}"
replacenull=STRING|"1"
varname=STRING|"SOURCE"
[Actions\Action3]
ActionID=STRING|"A_TXT_COOMATEXT"
Enabled=INTEGER|-1
Name=STRING|"Comma-separated string -> text"
Params=FOLDER
[Actions\Action3\Params]
kind=STRING|"0"
line00000000=STRING|"{source}"
lines=STRING|"1"
variable=STRING|"txt"
[Actions\Action4]
ActionID=STRING|"A_TXT_NUMBEROFLINES"
Enabled=INTEGER|-1
Name=STRING|"TXT Number of Lines"
Params=FOLDER
[Actions\Action4\Params]
external=STRING|"0"
line00000000=STRING|"{txt}"
linecount=STRING|"1"
variable=STRING|"sz"
[Actions\Action5]
ActionID=STRING|"A_LOOP_SIMPLE"
Enabled=INTEGER|-1
Name=STRING|"Simple Loop"
Params=FOLDER
[Actions\Action5\Params]
begin=STRING|"1"
end=STRING|"{sz}"
variable=STRING|"NUM"
[Actions\Action6]
ActionID=STRING|"A_TXT_EXTRACTLINE"
Enabled=INTEGER|-1
Name=STRING|"TXT Extract Line"
Params=FOLDER
[Actions\Action6\Params]
external=STRING|"0"
line00000000=STRING|"{txt}"
linecount=STRING|"1"
linenum=STRING|"{num}"
variable=STRING|"line"
[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""VAR{NUM}"" with value ""{Line}"""
Params=FOLDER
[Actions\Action7\Params]
expand=STRING|"1"
varname=STRING|"VAR{NUM}"
varvalue=STRING|"{Line}"
[Actions\Action8]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
[Actions\Action9]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action9\Params]
message=STRING|"Soutce = {Source}"
type=STRING|"3"
E.g. If however, I pass it a CSV containing Sonic, The Hedgehog I get three variables.
It Appears to be splitting on paste why is this and how can I just get
As 2 variables
Code: Select all
PSA documents created in Microsoft Excel for testing
Oleg
Site Admin
Posts: 3201 Joined: Thu Jan 01, 1970 1:00 am
Contact:
Post
by Oleg » Wed Apr 27, 2022 4:43 pm
The string
is not standard comma-separated string
Standard coma-separated string is
To bring your string to standard mode use
Split text action
Also look at my example (see step#4)
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1351"
Hide=INTEGER|0
ID=INTEGER|744873048
LogOnAsUser=INTEGER|1
Name=STRING|"Comma separated demo"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""line"" with value ""Sonic,The Hedgehog"""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"line"
varvalue=STRING|"Sonic,The Hedgehog"
[Actions\Action2]
ActionID=STRING|"A_TXT_COOMATEXT"
Enabled=INTEGER|-1
Name=STRING|"Comma-separated string -> text"
Params=FOLDER
[Actions\Action2\Params]
kind=STRING|"0"
line00000000=STRING|"{line}"
lines=STRING|"1"
variable=STRING|"txt"
[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{Line}"""
Params=FOLDER
[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"{Line}"
msg1=STRING|"=================="
msg2=STRING|"{txt}"
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action4]
ActionID=STRING|"A_VARIABLES_DELIMITED"
Enabled=INTEGER|-1
Name=STRING|"Split Text"
Params=FOLDER
[Actions\Action4\Params]
colon=STRING|"0"
comma=STRING|"1"
other=STRING|"0"
quote=STRING|"0"
semocolon=STRING|"0"
space=STRING|"0"
spaceasone=STRING|"0"
string=STRING|"{line}"
tab=STRING|"0"
variable=STRING|"line"
[Actions\Action5]
ActionID=STRING|"A_TXT_COOMATEXT"
Enabled=INTEGER|-1
Name=STRING|"Comma-separated string -> text"
Params=FOLDER
[Actions\Action5\Params]
kind=STRING|"0"
line00000000=STRING|"{line}"
lines=STRING|"1"
variable=STRING|"txt"
[Actions\Action6]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{Line}"""
Params=FOLDER
[Actions\Action6\Params]
icon=STRING|"1"
msg0=STRING|"{Line}"
msg1=STRING|"=================="
msg2=STRING|"{txt}"
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
DK.Ideagen
Posts: 22 Joined: Wed Mar 09, 2022 10:33 pm
Post
by DK.Ideagen » Thu Apr 28, 2022 8:46 am
I have adapted the above into my task.
It is working, however I really need the ultimate data to not be wrapped in double quotes.
Is there an easy way to achieve this?
Oleg
Site Admin
Posts: 3201 Joined: Thu Jan 01, 1970 1:00 am
Contact:
Post
by Oleg » Thu Apr 28, 2022 9:22 am
You can use any string format.
But it you want to process string as comma-separated string in RoboTask you must to convert string into standard format.
I really need the ultimate data to not be wrapped in double quotes.
You can combine the string without quotes, no problem
But what do you du if your element contains comma char?
for example
first element
second element
this, comma test
When you will convert this to CSV line without quotes the line will contain 4 elements instead of 3
Oleg Yershov
DK.Ideagen
Posts: 22 Joined: Wed Mar 09, 2022 10:33 pm
Post
by DK.Ideagen » Thu Apr 28, 2022 10:03 am
To clarify
Splitting on comma is wanted
just not on space
I added double quotes so
is split into two lines
not
In reality I want
but only split on commas
Oleg
Site Admin
Posts: 3201 Joined: Thu Jan 01, 1970 1:00 am
Contact:
Post
by Oleg » Thu Apr 28, 2022 12:05 pm
Look at this example
To get it work as you want you must add only one step (see step #2, Split Text)
Is this a problem?
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1351"
Hide=INTEGER|0
ID=INTEGER|744873048
LogOnAsUser=INTEGER|1
Name=STRING|"Comma separated demo"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""line"" with value ""Sonic,The Hedgehog"""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"line"
varvalue=STRING|"Sonic,The Hedgehog"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_DELIMITED"
Enabled=INTEGER|-1
Name=STRING|"Split Text"
Params=FOLDER
[Actions\Action2\Params]
colon=STRING|"0"
comma=STRING|"1"
other=STRING|"0"
quote=STRING|"0"
semocolon=STRING|"0"
space=STRING|"0"
spaceasone=STRING|"0"
string=STRING|"{line}"
tab=STRING|"0"
variable=STRING|"TmpLine"
[Actions\Action3]
ActionID=STRING|"A_TXT_COOMATEXT"
Enabled=INTEGER|-1
Name=STRING|"Comma-separated string -> text"
Params=FOLDER
[Actions\Action3\Params]
kind=STRING|"0"
line00000000=STRING|"{TmpLine}"
lines=STRING|"1"
variable=STRING|"txt"
[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Source line: {Line}"""
Params=FOLDER
[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"Source line: {Line}"
msg1=STRING|"=================="
msg2=STRING|"result text:"
msg3=STRING|"{txt}"
msgcount=STRING|"4"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
DK.Ideagen
Posts: 22 Joined: Wed Mar 09, 2022 10:33 pm
Post
by DK.Ideagen » Fri May 06, 2022 9:18 am
I fixed this with a python script to
Oleg
Site Admin
Posts: 3201 Joined: Thu Jan 01, 1970 1:00 am
Contact:
Post
by Oleg » Fri May 06, 2022 9:49 am
DK.Ideagen wrote: ↑ Fri May 06, 2022 9:18 am
I fixed this with a python script to
There is the action
STR Replace
You can use it instead of python
Oleg Yershov