csv file

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

csv file

Post by dondada »

I need a task that will "look" at a csv file and save each row of data to a separate file. I the original file has 5 rows then I should end up with 5 files. If the original file has 8 rows then I need 8 files. Each file must contain just one row of data. How do I do that? Thanks for the help.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

csv file

Post by Oleg »

See example below. This task save each line of text into separate file. Each file have name FileName_lineN.ext where
FileName - original filename;
ext - original extension;
N - line number.

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

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1614811947
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task392"
Hide=INTEGER|0
ID=INTEGER|1546359054
Name=STRING|"one line per file"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=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]
caption=STRING|"Open File"
default=STRING|"None"
filter=STRING|"Text files|*.txt|All files|*.*|"
variable=STRING|"FILE_TO_PROCESS"

[Actions\Action10]
ActionID=STRING|"A_VARIABLES_REMOVE"
Enabled=INTEGER|-1
Name=STRING|"Remove variable ""NEWFILENAME"""
Params=FOLDER

[Actions\Action10\Params]
varname=STRING|"NEWFILENAME"

[Actions\Action11]
ActionID=STRING|"A_VARIABLES_REMOVE"
Enabled=INTEGER|-1
Name=STRING|"Remove variable ""CUR_LINE"""
Params=FOLDER

[Actions\Action11\Params]
varname=STRING|"CUR_LINE"

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

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

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

[Actions\Action3\Params]
destvar=STRING|"CUR_LINE"
file=STRING|"{file_to_process}"
linecount=STRING|"0"
sourcetext=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWFILENAME"" with value ""{ExtractFilePath({File_to_process})}\{ExtractFileNameNoExt ({File_to_process})}_Line{num}.{ExtractFileExt({File_to_proc ess})}"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"1"
varname=STRING|"NEWFILENAME"
varvalue=STRING|"{ExtractFilePath({File_to_process})}\{Extra ctFileNameNoExt({File_to_process})}_Line{num}.{ExtractFileEx t({File_to_process})}"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{NewFileName}"""
Params=FOLDER

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

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

[Actions\Action6\Params]
fileexists=STRING|"0"
filname=STRING|"{NewFileName}"
line0=STRING|"{Cur_Line}"
linecount=STRING|"1"

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

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

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

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_REMOVE"
Enabled=INTEGER|-1
Name=STRING|"Remove variable ""NUM"""
Params=FOLDER

[Actions\Action9\Params]
varname=STRING|"NUM"
Post Reply