Skip to content

Instantly share code, notes, and snippets.

@neilkod
Created December 15, 2011 22:47
Show Gist options
  • Save neilkod/1483313 to your computer and use it in GitHub Desktop.
Save neilkod/1483313 to your computer and use it in GitHub Desktop.
super-hacky script to get the good stuff out of a teradata fastload log
cat parse_fastload_log.py
import re
logfile="/var/opt/sports_dw/dev/td_sports/td_sports_log/pt_email_dim.log"
values = {}
items = ['Total Records Read',
'Total Error Table 1',
'Total Error Table 2',
'Total Inserts Applied',
'Total Duplicate Rows']
with open(logfile) as f:
data = f.readlines()
total_records_read = 0
for line in data:
if line.find('insert into') > 0:
table_name = line.split()[3]
for item in items:
if line.find(item) >0:
values[item] = re.findall('[0-9]{1,}', line)[-1]
print "Table Name: %s" % table_name
print " "
for k,v in values.iteritems():
print "%s: %s" % (k,v)
-bash-3.1$ python parse_fastload_log.py
Table Name: sports_writer_dev.pt_email_dim_t
Total Inserts Applied: 39665245
Total Duplicate Rows: 0
Total Error Table 1: 0
Total Records Read: 39665245
Total Error Table 2: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment