csv edit

Discuss RoboTask here
Post Reply
dbortunk
Posts: 27
Joined: Mon Jun 08, 2009 10:38 am

csv edit

Post by dbortunk »

I have a CSV file the has two fields on each line seperated by a comma. Some of the lines only have the comma starting the line and then the username. I want to remove all lines that start with a ,For example, user112345, user267891, user3, user423456, user5Should end up like12345, user267891, user323456, user5
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

csv edit

Post by Oleg »

See the example below.
You can set the file name of CSV file at step #1
The task creates corrected CSV file with name {CSVFile}.new

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task17"
Hide=INTEGER|0
ID=INTEGER|2026014808
LogOnAsUser=INTEGER|1
Name=STRING|"correct CSV"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=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 local variable ""CSVFILE"" with value ""D:\Temp\test.csv"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"CSVFILE"
varvalue=STRING|"D:\Temp\test.csv"

[Actions\Action10]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""Notepad.exe ""{csvfile}.new"""""
Params=FOLDER

[Actions\Action10\Params]
ifnonzero=STRING|"0"
params=STRING|"""{csvfile}.new"""
program=STRING|"Notepad.exe"
runas=STRING|"0"
wait=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""CLINE"" with value """""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"CLINE"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""NEWTEXT"" with value """""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"NEWTEXT"

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

[Actions\Action4\Params]
destvar=STRING|"CLINE"
file=STRING|"{csvfile}"
linecount=STRING|"0"
sourcetext=STRING|"0"

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

[Actions\Action5\Params]
case=STRING|"0"
operator=STRING|"8"
type=STRING|"0"
value1=STRING|"{cline(0)}"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWTEXT"" with value ""{newText}{cline}{EOL}"""
Params=FOLDER

[Actions\Action6\Params]
expand=STRING|"1"
varname=STRING|"NEWTEXT"
varvalue=STRING|"{newText}{cline}{EOL}"

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

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

[Actions\Action9]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {csvFile}.new"
Params=FOLDER

[Actions\Action9\Params]
fileexists=STRING|"0"
filname=STRING|"{csvFile}.new"
line0=STRING|"{newtext}"
linecount=STRING|"1"
suppress=STRING|"1"

[\Comment]
s1=I have a CSV file the has two fields on each line seperated by a comma.
s2=Some of the lines only have the comma starting the line and then the username. I want to remove all lines that start with a ,
s3=For example
s4=, user1
s5=12345, user2
s6=67891, user3
s7=, user4
s8=23456, user5
s9=Should end up like
s10=12345, user2
s11=67891, user3
s12=23456, user5
Post Reply