CSV DATA LOOP

Discuss RoboTask here
Post Reply
photoevents
Posts: 47
Joined: Mon Jan 01, 2024 11:21 am
Contact:

CSV DATA LOOP

Post by photoevents »

I have a csv file which is constantly being updated with new rows.

What I want to do is to copy this file over to a workfolder,
then loop it and do something with the variables
then repeat the process but now taking into account the lines that already have been processed.

I was thinking when opening CSV open Data to use a variable (linecounter) and put that in Skip first lines, so it starts in the next loop with the new lines added.

I'm a bit stuck
perhaps you could advice on a better approach?
Not that i need code just some advice,

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|345416516
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task12"
Hide=INTEGER|0
ID=INTEGER|-267299765
LogOnAsUser=INTEGER|1
Name=STRING|"CSV Open Data..."
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create global variable ""row_counter_total"" with value ""0"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"row_counter_total"
expand=STRING|"0"
linecount=STRING|"1"
varkind=STRING|"0"
varname=STRING|"row_counter_total"
varvalue=STRING|"0"

[Actions\Action10]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{voornaam}"""
Params=FOLDER

[Actions\Action10\Params]
icon=STRING|"1"
msg0=STRING|"{voornaam}"
msg1=STRING|"{wens}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action11]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay 1 sec"
Params=FOLDER

[Actions\Action11\Params]
delay=STRING|"1"
dimension=STRING|"1"

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

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

[Actions\Action13\Params]
incement=STRING|"{var_row}"
vaiable=STRING|"row_counter_total"

[Actions\Action14]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{row_counter_total}"""
Params=FOLDER

[Actions\Action14\Params]
icon=STRING|"1"
msg0=STRING|"{row_counter_total}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action15]
ActionID=STRING|"A_FLOW_GOTO"
Enabled=INTEGER|-1
Name=STRING|"GoTo step #2"
Params=FOLDER

[Actions\Action15\Params]
step=STRING|"2"
uselabel=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_FLOW_LABEL"
Enabled=INTEGER|-1
Name=STRING|"Label: Label1"
Params=FOLDER

[Actions\Action2\Params]
name=STRING|"Label1"

[Actions\Action3]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER

[Actions\Action3\Params]
checkfile=STRING|"1"
destdir=STRING|"S:\onedrive_photoevents\photoevents\makeawish"
f_count=STRING|"1"
file0=STRING|"W:\WISH\MAKEAWISH\storage\csv\form-results.csv"
hidden=STRING|"0"
ifexists=STRING|"0"
maxtimeout=STRING|"5"
move=STRING|"0"
output=STRING|"0"
rename=STRING|"1"
renamemask=STRING|"form-results-workfile.csv"
subdir=STRING|"0"
system=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_CSV_OPEN"
Enabled=INTEGER|-1
Name=STRING|"CSV Open Data"
Params=FOLDER

[Actions\Action4\Params]
commentchars=STRING|"#"
delimiter=STRING|"0"
encoding=STRING|"0"
filename=STRING|"S:\onedrive_photoevents\photoevents\makeawish\form-results-workfile.csv"
headerline=STRING|"1"
linecount=STRING|"0"
quotechar=STRING|"0"
skipcomments=STRING|"0"
skipempty=STRING|"1"
skipfirst=STRING|"0"
source=STRING|"1"
strictdelimiter=STRING|"1"

[Actions\Action5]
ActionID=STRING|"A_CSV_INFO"
Enabled=INTEGER|-1
Name=STRING|"CSV Get Data Information"
Params=FOLDER

[Actions\Action5\Params]
_rt_variables_produced=STRING|"las_column_count,last_row_count"
colcountvar=STRING|"las_column_count"
commentchars=STRING|"#"
delimiter=STRING|"2"
encoding=STRING|"0"
headerline=STRING|"0"
linecount=STRING|"0"
quotechar=STRING|"0"
recordcountvar=STRING|"last_row_count"
skipcomments=STRING|"0"
skipempty=STRING|"1"
skipfirst=STRING|"0"
source=STRING|"0"
strictdelimiter=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{last_row_count} rows"""
Params=FOLDER

[Actions\Action6\Params]
icon=STRING|"1"
msg0=STRING|"{last_row_count} rows"
msg1=STRING|"{las_column_count} columns"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{row_counter_total}"""
Params=FOLDER

[Actions\Action7\Params]
icon=STRING|"1"
msg0=STRING|"{row_counter_total}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action8]
ActionID=STRING|"A_CSV_LOOP"
Enabled=INTEGER|-1
Name=STRING|"CSV Data Loop"
Params=FOLDER

[Actions\Action8\Params]
_rt_variables_produced=STRING|"var_row,var_value"
commentchars=STRING|"#"
conditionmode=STRING|"0"
conditionscount=STRING|"0"
delimiter=STRING|"2"
encoding=STRING|"0"
Format=STRING|"0"
headerline=STRING|"0"
linecount=STRING|"0"
linevarname=STRING|"var_value"
quotechar=STRING|"0"
rowvarname=STRING|"var_row"
skipcomments=STRING|"0"
skipempty=STRING|"1"
skipfirst=STRING|"0"
source=STRING|"0"
strictdelimiter=STRING|"1"

[Actions\Action9]
ActionID=STRING|"A_CSV_READCELLS"
Enabled=INTEGER|-1
Name=STRING|"CSV Read Cells"
Params=FOLDER

[Actions\Action9\Params]
_rt_variables_produced=STRING|"voornaam,wens"
cellcount=STRING|"2"
col0=STRING|"1"
col1=STRING|"3"
commentchars=STRING|"#"
delimiter=STRING|"2"
encoding=STRING|"0"
headerline=STRING|"0"
linecount=STRING|"0"
quotechar=STRING|"0"
row0=STRING|"{var_row}"
row1=STRING|"{var_row}"
skipcomments=STRING|"0"
skipempty=STRING|"1"
skipfirst=STRING|"0"
source=STRING|"0"
strictdelimiter=STRING|"1"
val0=STRING|"voornaam"
val1=STRING|"wens"

Thanks,
Christian
Oleg
Site Admin
Posts: 3135
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: CSV DATA LOOP

Post by Oleg »

Which variable contains the number of lines processed? row_counter_total, correct?
1. In this case you don't need to create it in 1-st step. You must create it somewhere outside the task (for example manually)

2. You can simply skip processed rows
do something like this:

Code: Select all

CSV data loop 
   if {var_row} > {row_counter_total} then
      read cells
      do something else
   end if
end loop

3. I see that your task works indefinitely. This is a very bad idea. It's better to start task periodically. Look at the Cyclic trigger. For example every 5-10 seconds.
Oleg Yershov
photoevents
Posts: 47
Joined: Mon Jan 01, 2024 11:21 am
Contact:

Re: CSV DATA LOOP

Post by photoevents »

Thank you,
That helps,
Again ;-)

Christian
Post Reply