1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: GBK -*-
#¶ÁÈ¡Excel±£´æµÄÅäÖÃÎļþµÄ±ãÀû·â×°À࣬¿ÉÒÔÉèÖúöÂÔµÄÐкÍÁеÄÊýÁ¿
# author: Alee
# Date: 2011.9.1
# history:  2011.9.1     Created
 
 
import logging
import traceback
 
class DataFileReader(object):
    _SKIP_LINES = 1
    _SKIP_COLUMNS = 1
    def __init__( self ):
        pass
 
    def _ProcessData( self, datalist ):
        pass
 
    def _ProcessLine( self, line ):
        new = line.replace( "\n", "\t" )
        e = new.split( "\t" )
        skip = self._SKIP_COLUMNS
        self._ProcessData( e[skip:] )
 
    def Open( self, filename ):
        try:
            fp = open( filename )
        except Exception, e:
            print str(e)
            print traceback.print_exc()
            logging.error( str(e) )
            logging.error( traceback.print_exc() )
            return False
 
        skip = self._SKIP_LINES
        for line in fp:
            if 0 == skip:
                self._ProcessLine( line )
            else:
                skip -= 1
                continue
        return True