[Python-checkins] python/dist/src/Lib/csv/util sniffer.py,1.1,1.2

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Thu, 24 Apr 2003 09:03:21 -0700


Update of /cvsroot/python/python/dist/src/Lib/csv/util
In directory sc8-pr-cvs1:/tmp/cvs-serv21022/Lib/csv/util

Modified Files:
	sniffer.py 
Log Message:
Whitespace normalization.


Index: sniffer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/csv/util/sniffer.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** sniffer.py	20 Mar 2003 23:31:24 -0000	1.1
--- sniffer.py	24 Apr 2003 16:02:48 -0000	1.2
***************
*** 27,33 ****
          Takes a file-like object and returns a dialect (or None)
          """
!         
          self.fileobj = fileobj
!         
          data = fileobj.read(self.sample)
  
--- 27,33 ----
          Takes a file-like object and returns a dialect (or None)
          """
! 
          self.fileobj = fileobj
! 
          data = fileobj.read(self.sample)
  
***************
*** 52,60 ****
      def hasHeaders(self):
          return self._hasHeaders(self.fileobj, self.dialect)
!     
  
      def register_dialect(self, name = 'sniffed'):
          csv.register_dialect(name, self.dialect)
!     
  
      def _guessQuoteAndDelimiter(self, data):
--- 52,60 ----
      def hasHeaders(self):
          return self._hasHeaders(self.fileobj, self.dialect)
! 
  
      def register_dialect(self, name = 'sniffed'):
          csv.register_dialect(name, self.dialect)
! 
  
      def _guessQuoteAndDelimiter(self, data):
***************
*** 79,83 ****
              if matches:
                  break
!         
          if not matches:
              return ('', None, 0) # (quotechar, delimiter, skipinitialspace)
--- 79,83 ----
              if matches:
                  break
! 
          if not matches:
              return ('', None, 0) # (quotechar, delimiter, skipinitialspace)
***************
*** 118,122 ****
              delim = ''
              skipinitialspace = 0
!             
          return (quotechar, delim, skipinitialspace)
  
--- 118,122 ----
              delim = ''
              skipinitialspace = 0
! 
          return (quotechar, delim, skipinitialspace)
  
***************
*** 133,144 ****
               7 times in 2 rows"
            3) use the mode of the meta-frequency to determine the /expected/
!              frequency for that character 
!           4) find out how often the character actually meets that goal 
!           5) the character that best meets its goal is the delimiter 
          For performance reasons, the data is evaluated in chunks, so it can
          try and evaluate the smallest portion of the data possible, evaluating
!         additional chunks as necessary. 
          """
!         
          data = filter(None, data.split('\n'))
  
--- 133,144 ----
               7 times in 2 rows"
            3) use the mode of the meta-frequency to determine the /expected/
!              frequency for that character
!           4) find out how often the character actually meets that goal
!           5) the character that best meets its goal is the delimiter
          For performance reasons, the data is evaluated in chunks, so it can
          try and evaluate the smallest portion of the data possible, evaluating
!         additional chunks as necessary.
          """
! 
          data = filter(None, data.split('\n'))
  
***************
*** 219,223 ****
          # all of the rows except for the first are the same length, it's a header.
          # Finally, a 'vote' is taken at the end for each column, adding or subtracting from
!         # the likelihood of the first row being a header. 
  
          def seval(item):
--- 219,223 ----
          # all of the rows except for the first are the same length, it's a header.
          # Finally, a 'vote' is taken at the end for each column, adding or subtracting from
!         # the likelihood of the first row being a header.
  
          def seval(item):
***************
*** 228,232 ****
  
          fileobj.seek(0) # rewind the fileobj - this might not work for some file-like objects...
!         
          reader = csv.reader(fileobj,
                              delimiter = dialect.delimiter,
--- 228,232 ----
  
          fileobj.seek(0) # rewind the fileobj - this might not work for some file-like objects...
! 
          reader = csv.reader(fileobj,
                              delimiter = dialect.delimiter,
***************
*** 285,289 ****
  
          return hasHeader > 0
- 
- 
- 
--- 285,286 ----