I have a good few hundred of these job metric definitions in a single file that I'm trying to parse into a formatted .csv document
Job Name Last Start Last End ST Run Pri/Xit
________________________________________________________________ ____________________ ____________________ __ _______ ___
B9043CC_APP_DMLD_025_FR_xpabbdu1_D 03/12/2014 18:21:32 03/12/2014 18:22:07 SU 49744331/3
Status/[Event] Time Ntry ES ProcessTime Machine
-------------- --------------------- -- -- --------------------- ----------------------------------------
[FORCE_STARTJOB] 03/12/2014 17:30:52 0 PD 03/12/2014 17:30:53
< >
STARTING 03/12/2014 17:30:53 1 PD 03/12/2014 17:30:53 ab-shared-batch
RUNNING 03/12/2014 17:31:06 1 PD 03/12/2014 17:31:07 ab-shared-batch
SUCCESS 03/12/2014 17:31:46 1 PD 03/12/2014 17:31:47
[FORCE_STARTJOB] 03/12/2014 18:16:06 0 PD 03/12/2014 18:16:07
< >
STARTING 03/12/2014 18:16:07 2 PD 03/12/2014 18:16:07 ab-shared-batch-
RUNNING 03/12/2014 18:16:19 2 PD 03/12/2014 18:16:20 ab-shared-batch-
FAILURE 03/12/2014 18:17:02 2 PD 03/12/2014 18:17:03
[*** ALARM ***]
JOBFAILURE 03/12/2014 18:17:03 2 PD 03/12/2014 18:17:04
[FORCE_STARTJOB] 03/12/2014 18:21:18 0 PD 03/12/2014 18:21:19
< >
STARTING 03/12/2014 18:21:19 3 PD 03/12/2014 18:21:19 ab-shared-batch-
RUNNING 03/12/2014 18:21:32 3 PD 03/12/2014 18:21:32 ab-shared-batch-
SUCCESS 03/12/2014 18:22:07 3 PD 03/12/2014 18:22:08
I would like my output to look at this:System Number Command Job name Box Job Name
System Number Job Name Target Machiene Status Actual Start Date Actual Start Time Actual End Date Actual End Time
9043 B9043CC_APP_DMLD_025_FR_xpabbdu1_D ab-shared-batch SUCCESS 03/12/2014 17:30:53 03/12/2014 17:31:47
9043 B9043CC_APP_DMLD_025_FR_xpabbdu1_D ab-shared-batch FAILURE 03/12/2014 18:16:07 03/12/2014 18:17:03
9043 B9043CC_APP_DMLD_025_FR_xpabbdu1_D ab-shared-batch SUCCESS 03/12/2014 18:21:19 03/12/2014 18:22:08
The actual start/end times & actaul start/end dates are coming from the "Process time" column.I only want the data above and don't want any of the text including the "----" to be anywhere in the .csv file. As mentioned above, I have a few hundred of those definitions in a single file.
I know python has a built in csv module which I am using to write to the label colums:
import csv
import sys
infile = '/home/n5acc7/test/output/testtest.csv'
f = open(infile, 'wt')
try:
writer = csv.writer(f)
writer.writerow( ('System Number', 'Job Name' 'Target Machiene', 'Status', 'Actual Start Date' 'Actual Start Date', 'Actual End Time', 'Actual End Date', 'Actual End Time',) )
finally:
f.close()
But from the parsing persepctive, I'm not sure where to start. I'm running python 2.4.3.