Howto: Read a CSV file with Automic Script
search cancel

Howto: Read a CSV file with Automic Script

book

Article ID: 89810

calendar_today

Updated On:

Products

CA Automic Workload Automation - Automation Engine

Issue/Introduction

Howto: Read a CSV file with Automic Script

Environment

Release: AUTWAB99000-10.0-Automic Workload Automation-Base Edition
Component:

Resolution

UnfortunatelyMicrosoft Excel XLSX Files do not store their content in cleartext but in a bitcomplicated XML structure.

CSV Filesdo, so its easy to read their content with Automic script command PREP_PROCESS_FILE.

The onlything we have to look for is the delimiter character ";"

 

If you opena CSV file with a common editor you see:

a;1;schubiduba

b;2;oleole

c;3;heureka

 

To get thecontent of this CSV File into Automation Engine  you can use following script:

(NOTE: you needone command GET_PROCESS_LINE for each column of the CSV file)

 

:SET&HND# = PREP_PROCESS_FILE(WS10_VWGSUP15_WX6_02_SYS,"C:\Temp\testbrw.csv",,"COL=DELIMITER,DELIMITER=*;*")

:PROCESS&HND#

: SET &LINE1# =GET_PROCESS_LINE(&HND#,1)

: SET &LINE2# =GET_PROCESS_LINE(&HND#,2)

: SET &LINE3# =GET_PROCESS_LINE(&HND#,3)

: PRINT "&LINE1# -- &LINE2# --&LINE3#"

:ENDPROCESS

:close_process &HND#

 

Report:

2015-07-0714:03:53 - U0020408 a -- 1 -- schubiduba

2015-07-0714:03:53 - U0020408 b -- 2 -- oleole

2015-07-0714:03:53 - U0020408 c -- 3 -- heureka

 

 

If you onlywant the 3rd column processed, then only use the GET_PROCESS_LINEcommand with parameter for the 3rd column of the CSV File:

 

:SET&HND# = PREP_PROCESS_FILE(WS10_VWGSUP15_WX6_02_SYS,"C:\Temp\testbrw.csv",,"COL=DELIMITER,DELIMITER=*;*")

:PROCESS&HND#

: SET &LINE3# =GET_PROCESS_LINE(&HND#,3)

: PRINT "Word of the day:&LINE3#"

:ENDPROCESS

:close_process &HND#

 

Report:

2015-07-0714:03:53 - U0020408 Word of the day: schubiduba

2015-07-0714:03:53 - U0020408 Word of the day: oleole

2015-07-0714:03:53 - U0020408 Word of the day: heureka



For further information to the PREP_PROCESS_FILE command please refer to:

http://docs.automic.com/documentation/AE/10.0.5/german/AE_WEBHELP/help.htm#ucaafq.htm?Highlight=prep_process_file