Home

alexander smishlajev

Python module for reading and writing DBF files. Originally it was created by Jeff Kunce and later maintained by Hans Fiby.


Project Admins:


  • Fran García
    Fran García
    2013-10-28

    Bug: Reading (decoding) values ​​'' with dbfpy
    Module: fields.py
    Function: decodevalue()
    Description:
    When a DBF-file has the * (,
    , ...) character in one of the fields, an error message appears

    'invalid literal for int() with base 10: '***' '

    I propose the following change to the decode function:

    def decodeValue(self, value):
        """Return a number decoded from ``value``.
    
        If decimals is zero, value will be decoded as an integer;
        or as a float otherwise.
    
        Return:
            Return value is a int (long) or float instance.
    
        """
        value = value.strip(" \0")
        if "." in value:
            # a float (has decimal separator)
            return float(value)
    
        # NEW francisgg: * per whitespaces
        if "*" in value:
           value=value.replace('*', ' ')
           return value
    
        elif value:
            # must be an integer                
            return int(value)
        else:
            return 0
    

    Finally, I am a beginner and I hope your opinion.