Reading the text

Discuss RoboTask here
Post Reply
dondada
Posts: 22
Joined: Fri May 20, 2005 11:30 am

Reading the text

Post by dondada »

How do I save the text in the 2nd line 5th column of a .csv file to a variable and then write the variable to a different text file? I can do everything except getting the value on the 2nd line 5th column.
Please help! Thanks 
 
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Reading the text

Post by Oleg »

You can access to a part of user variable, which contains a comma-separated string so:
{My_var(0)}
{My_var(1)}
and so on. Index number is beginning from 0. I advise you to use "Delimited variable" action to normalize your delimited string. This action can transform any delimited strings to standard state.
Delimited variable action is in variables plugin.
Last edited by Oleg on Tue Aug 16, 2005 2:00 pm, edited 1 time in total.
dondada
Posts: 22
Joined: Fri May 20, 2005 11:30 am

Reading the text

Post by dondada »

Could you please write a task that shows how. Thanks!
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Reading the text

Post by Oleg »

Of course, see below

;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|565106205
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task293"
Hide=INTEGER|0
ID=INTEGER|1714365089
Name=STRING|"Delimited strings demo"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

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

[Actions\Action1\Params]
destvar=STRING|"C_LINE"
line0=STRING|"Fist string; First Value; 125"
line1=STRING|"""Second string""; second value; 300"
linecount=STRING|"2"
sourcetext=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_DELIMITED"
Enabled=INTEGER|-1
Name=STRING|"Delimited Variable"
Params=FOLDER

[Actions\Action2\Params]
colon=STRING|"0"
comma=STRING|"0"
other=STRING|"0"
quote=STRING|"0"
semocolon=STRING|"1"
space=STRING|"0"
spaceasone=STRING|"0"
string=STRING|"{c_Line}"
tab=STRING|"0"
variable=STRING|"c_line1"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Original string """
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"Original string "
msg1=STRING|"{c_line}"
msg3=STRING|"Normalized string"
msg4=STRING|"{c_line1}"
msg6=STRING|"Value0 = {c_line1(0)}"
msg7=STRING|"Value1 = {c_line1(1)}"
msg8=STRING|"Value2 = {c_line1(2)}"
msgcount=STRING|"9"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
dondada
Posts: 22
Joined: Fri May 20, 2005 11:30 am

Reading the text

Post by dondada »

I tried the task you wrote and it did not work despite all the modifications that I could think of trying! I emailed you the actual csv file that I am working with. Please help me make it work. Thanks!
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Reading the text

Post by Oleg »

I haven’t received any CSV files.
Please, send again and describe in detail, what do you want to do.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Reading the text

Post by Oleg »

See task below. It reads your CSV file from c:\new.csv. Remember, that number of fields begins from 0, therefore 5-th field have a number 4. If you don't understand anything, feel free to ask again.

;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|565106205
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task297"
Hide=INTEGER|0
ID=INTEGER|197615729
Name=STRING|"5-th field on 2-nd line"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

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

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""EMAIL_FROM_CSV"" with value """""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"EMAIL_FROM_CSV"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""CSV_LINE_NUMBER"" with value ""1"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"CSV_LINE_NUMBER"
varvalue=STRING|"1"

[Actions\Action3]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER

[Actions\Action3\Params]
destvar=STRING|"CSV_LINE"
file=STRING|"C:\new.csv"
linecount=STRING|"0"
sourcetext=STRING|"0"

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

[Actions\Action4\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"1"
value1=STRING|"{csv_line_number}"
value2=STRING|"2"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""EMAIL_FROM_CSV"" with value ""{csv_line(4)}"""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"1"
varname=STRING|"EMAIL_FROM_CSV"
varvalue=STRING|"{csv_line(4)}"

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

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

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

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

[Actions\Action9]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Extacted email is:"""
Params=FOLDER

[Actions\Action9\Params]
icon=STRING|"1"
msg0=STRING|"Extacted email is:"
msg1=STRING|"{email_from_csv}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"

Last edited by Oleg on Sun Aug 28, 2005 12:49 pm, edited 1 time in total.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Reading the text

Post by Oleg »

Please, pay attention that you must turn on "Expand variable value" checkbox when you assign the value to EMAIL_FROM_CSV variable.
Post Reply