Read a Textfile , Append, Save Textfile

Discuss RoboTask here
Post Reply
gremlin
Posts: 9
Joined: Sun Jan 08, 2023 3:13 pm

Read a Textfile , Append, Save Textfile

Post by gremlin »

Hy,
I had a problem.
Robotask can´t Read / Write a Textfile.
Snipaste_2023-01-20_12-32-53.png
Snipaste_2023-01-20_12-32-53.png (10.22 KiB) Viewed 171 times

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|1
Events=FOLDER
ExternalName=STRING|"Task4"
Hide=INTEGER|0
ID=INTEGER|736713264
LocalVariables=STRING|"DATEIUNDPFAD="
LogOnAsUser=INTEGER|1
Name=STRING|"Sander EP"
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
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_DIALOG_INPUTBOX"
Enabled=INTEGER|-1
Name=STRING|"Input Box"
Params=FOLDER

[Actions\Action1\Params]
password=STRING|"0"
prompt=STRING|"Länge"
stopifcancel=STRING|"0"
variable=STRING|"LAENGE"

[Actions\Action2]
ActionID=STRING|"A_DIALOG_INPUTBOX"
Enabled=INTEGER|-1
Name=STRING|"Input Box"
Params=FOLDER

[Actions\Action2\Params]
password=STRING|"0"
prompt=STRING|"Breite"
stopifcancel=STRING|"0"
variable=STRING|"BREITE"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_INPUTBOX"
Enabled=INTEGER|-1
Name=STRING|"Input Box"
Params=FOLDER

[Actions\Action3\Params]
password=STRING|"0"
prompt=STRING|"Höhe"
stopifcancel=STRING|"0"
variable=STRING|"HOEHE"

[Actions\Action4]
ActionID=STRING|"A_READ_TXTFILE"
Enabled=INTEGER|-1
Name=STRING|"Read Text File ""{DATEIUNDPFAD}"" (1252)"
Params=FOLDER

[Actions\Action4\Params]
codepage=STRING|"1252"
filename=STRING|"{DATEIUNDPFAD}"
replacenull=STRING|"0"
varname=STRING|"CSV"

[Actions\Action5]
ActionID=STRING|"A_STR_TRIM"
Enabled=INTEGER|-1
Name=STRING|"STR Trim"
Params=FOLDER

[Actions\Action5\Params]
custom=STRING|"0"
eol=STRING|"0"
lead=STRING|"1"
source=STRING|"CSV"
spaces=STRING|"1"
tabs=STRING|"1"
trailing=STRING|"1"
variable=STRING|"CSV"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set varible ""NEWFILENAME1"" with value ""C:\Temp\Dst\{ExtractFileNameNoExt({FileToProcess})}[{Year}-{MonthNo}-{Day}][{Hours}-{Minutes}-{Seconds}].{ExtractFileExt({FileToProcess})}"""
Params=FOLDER

[Actions\Action6\Params]
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"NEWFILENAME1"
varvalue=STRING|"c:\JTL-TMP\{Year}{MonthNo}{Day}{Time}{Seconds}.csv"

[Actions\Action7]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {NEWFILENAME1}"
Params=FOLDER

[Actions\Action7\Params]
encode=STRING|"0"
fileexists=STRING|"0"
filname=STRING|"{NEWFILENAME1}"
line0=STRING|"{CSV}{LAENGE};{BREITE};{HOEHE};;;;"
linecount=STRING|"1"
suppress=STRING|"0"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_FILE_MONITOR"
Name=STRING|"File Monitor"
Params=FOLDER
UniqueID=INTEGER|-263111290

[Events\Event1\Params]
chg=STRING|"0"
chga=STRING|"1"
chgsl=STRING|"1"
chgsm=STRING|"1"
chgtl=STRING|"1"
chgtm=STRING|"1"
del=STRING|"0"
folder1=STRING|"C:\JTL-TMP"
foldercount=STRING|"1"
incmask=STRING|"Sander-EP.csv"
interval=STRING|"10"
listmode=STRING|"1"
mon_files=STRING|"1"
mon_folders=STRING|"0"
new=STRING|"1"
newlistparameter=STRING|"DATEIUNDPFAD"
notsavestatus=STRING|"0"
onelistparameter=STRING|"DATEIUNDPFAD"
pass=STRING|"1"
passmode=STRING|"1"
required=STRING|"0"
saveresults=STRING|"0"
subfolders1=STRING|"0"

Maybe anyone can help me.
Oleg
Site Admin
Posts: 2846
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Read a Textfile , Append, Save Textfile

Post by Oleg »

Could you send the file "Sander-EP.csv" for investigation to me to oleg(at)robotask.com
Probably your file contain some restricted symbols for code page 1252

Also try this task
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.
Do not forget to enable the task after importing.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|693415217
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|1
Events=FOLDER
ExternalName=STRING|"Task44"
Hide=INTEGER|0
ID=INTEGER|212909958
LocalVariables=STRING|"DATEIUNDPFAD="
LogOnAsUser=INTEGER|1
Name=STRING|"Sander EP (v2)"
OnErrorTaskID=INTEGER|1879502808
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
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_DIALOG_INPUTBOX"
Enabled=INTEGER|-1
Name=STRING|"Input Box"
Params=FOLDER

[Actions\Action1\Params]
password=STRING|"0"
prompt=STRING|"Länge"
stopifcancel=STRING|"0"
variable=STRING|"LAENGE"

[Actions\Action2]
ActionID=STRING|"A_DIALOG_INPUTBOX"
Enabled=INTEGER|-1
Name=STRING|"Input Box"
Params=FOLDER

[Actions\Action2\Params]
password=STRING|"0"
prompt=STRING|"Breite"
stopifcancel=STRING|"0"
variable=STRING|"BREITE"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_INPUTBOX"
Enabled=INTEGER|-1
Name=STRING|"Input Box"
Params=FOLDER

[Actions\Action3\Params]
password=STRING|"0"
prompt=STRING|"Höhe"
stopifcancel=STRING|"0"
variable=STRING|"HOEHE"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""CSV"" with value ""{TextFile({DATEIUNDPFAD})}"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"1"
linecount=STRING|"1"
varname=STRING|"CSV"
varvalue=STRING|"{TextFile({DATEIUNDPFAD})}"

[Actions\Action5]
ActionID=STRING|"A_STR_TRIM"
Enabled=INTEGER|-1
Name=STRING|"STR Trim"
Params=FOLDER

[Actions\Action5\Params]
custom=STRING|"0"
eol=STRING|"0"
lead=STRING|"1"
source=STRING|"CSV"
spaces=STRING|"1"
tabs=STRING|"1"
trailing=STRING|"1"
variable=STRING|"CSV"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set varible ""NEWFILENAME1"" with value ""C:\Temp\Dst\{ExtractFileNameNoExt({FileToProcess})}[{Year}-{MonthNo}-{Day}][{Hours}-{Minutes}-{Seconds}].{ExtractFileExt({FileToProcess})}"""
Params=FOLDER

[Actions\Action6\Params]
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"NEWFILENAME1"
varvalue=STRING|"c:\JTL-TMP\{Year}{MonthNo}{Day}{Time}{Seconds}.csv"

[Actions\Action7]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {NEWFILENAME1}"
Params=FOLDER

[Actions\Action7\Params]
encode=STRING|"0"
fileexists=STRING|"0"
filname=STRING|"{NEWFILENAME1}"
line0=STRING|"{CSV}{LAENGE};{BREITE};{HOEHE};;;;"
linecount=STRING|"1"
suppress=STRING|"0"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_FILE_MONITOR"
Name=STRING|"File Monitor"
Params=FOLDER
UniqueID=INTEGER|2081193478

[Events\Event1\Params]
chg=STRING|"0"
chga=STRING|"1"
chgsl=STRING|"1"
chgsm=STRING|"1"
chgtl=STRING|"1"
chgtm=STRING|"1"
del=STRING|"0"
folder1=STRING|"C:\JTL-TMP"
foldercount=STRING|"1"
incmask=STRING|"Sander-EP.csv"
interval=STRING|"10"
listmode=STRING|"1"
mon_files=STRING|"1"
mon_folders=STRING|"0"
new=STRING|"1"
newlistparameter=STRING|"DATEIUNDPFAD"
notsavestatus=STRING|"0"
onelistparameter=STRING|"DATEIUNDPFAD"
pass=STRING|"1"
passmode=STRING|"1"
required=STRING|"0"
saveresults=STRING|"0"
subfolders1=STRING|"0"

Oleg Yershov
gremlin
Posts: 9
Joined: Sun Jan 08, 2023 3:13 pm

Re: Read a Textfile , Append, Save Textfile

Post by gremlin »

Hy,
thank you.
I had tried but at the CSV file no variable output , only the name of the variable ...
Snipaste_2023-01-23_12-20-59.png
Snipaste_2023-01-23_12-20-59.png (9.17 KiB) Viewed 89 times
Also I must change the filename time with a : won´t write a filename ...

I had send you file via email

Thanks

Steven
Oleg
Site Admin
Posts: 2846
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Read a Textfile , Append, Save Textfile

Post by Oleg »

":" is restricted symbol in file name.
Also you can not use several other symbols: *,?,\,/,",'
Oleg Yershov
gremlin
Posts: 9
Joined: Sun Jan 08, 2023 3:13 pm

Re: Read a Textfile , Append, Save Textfile

Post by gremlin »

Yes, I had solved this with the filename.
But at the outputfile there should be the variable {csv} string, not the name of the variable.
At the textfile 3 variables shows their value, but the {cvs} variable show only the text csv ???
Any idea ?

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

Re: Read a Textfile , Append, Save Textfile

Post by Oleg »

but the {cvs} variable show only the text csv ???
Look at the step #5 (STR Trim)
you must use expression {csv} as source string (not CSV)

CSV is only CSV nothing more. But the expression {CSV} tells RoboTask that there is a variable name between braces and the task must try to extract the value.
Oleg Yershov
Post Reply