#! /Usr/bin/env python
#-*-Coding: UTF-8 -*-
# Filename: file_process.py
# Function:
# Author: Liu Hongbo
# Date: 2012-05-07
Import glob
Import OS
Import re
# Log file directory
V_log_dir = '/etl/aiinsight/bin/py'
# Target file
F_tab1 = open ('/etl/aiinsight/bin/py/tab_pai_tab.txt', 'w ')
F_tab2 = open ('/etl/aiinsight/bin/py/tab_into_insert.txt', 'w ')
OS. chdir (v_log_dir)
# Display files of the specified type
# Query Regular Expressions
P1 = re. compile ('wwnew \. [\ w] + | DW \. [\ w] + | REPORT \. [\ w] + | TBOWNER \. [\ w] + ')
P2 = re. compile ('insert [\ s] + INTO [\ s] + WWNEW \. [\ w] + | INSERT [\ s] + INTO [\ s] + DW \. [\ w] + | INSERT [\ s] + INTO [\ s] + REPORT \. [\ w] + | INSERT [\ s] + INTO [\ s] + TBOWNER \. [\ w] + ')
For v_file in glob. glob ('*. log '):
F = open (v_file)
For line in f:
For v_tab in p1.findall (line. upper ()):
F_tab1.write (v_file + ',' + v_tab + '\ n ')
For v_tab in p2.findall (line. upper ()):
F_tab2.write (v_file + ',' + v_tab + '\ n ')
F. close ()
F_tab1.close ()
F_tab2.close ()
From drop-down stone