Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: could not convert string to float: F #8

Open
gijzelaerr opened this issue Aug 24, 2015 · 1 comment
Open

ValueError: could not convert string to float: F #8

gijzelaerr opened this issue Aug 24, 2015 · 1 comment

Comments

@gijzelaerr
Copy link

Hi! I tried your library to open a dbf file but get the following error:

import dbfread
file_ = '/home/gijs/.wine/drive_c/OLMSoft/BrouwVisie/Data/Recepten.Dbf'
t = dbfread.dbf.DBF(file_, load=True)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-33-e461b614b7c2> in <module>()
----> 1 t = dbfread.dbf.DBF(file_, load=True)

/usr/local/lib/python2.7/dist-packages/dbfread/dbf.pyc in __init__(self, filename, encoding, ignorecase, lowernames, parserclass, recfactory, load, raw, ignore_missing_memofile)
    131 
    132         if load:
--> 133             self.load()
    134 
    135     @property

/usr/local/lib/python2.7/dist-packages/dbfread/dbf.pyc in load(self)
    166         """
    167         if not self.loaded:
--> 168             self._records = list(self._iter_records(b' '))
    169             self._deleted = list(self._iter_records(b'*'))
    170 

/usr/local/lib/python2.7/dist-packages/dbfread/dbf.pyc in _iter_records(self, record_type)
    308                         items = [(field.name,
    309                                   parse(field, read(field.length))) \
--> 310                                  for field in self.fields]
    311 
    312                     yield self.recfactory(items)

/usr/local/lib/python2.7/dist-packages/dbfread/field_parser.pyc in parse(self, field, data)
     73             raise ValueError('Unknown field type: {!r}'.format(field.type))
     74         else:
---> 75             return func(field, data)
     76 
     77     def parse0(self, field, data):

/usr/local/lib/python2.7/dist-packages/dbfread/field_parser.pyc in parseN(self, field, data)
    162             else:
    163                 # Account for , in numeric fields
--> 164                 return float(data.replace(b',', b'.'))
    165 
    166     def parseO(self, field, data):

ValueError: could not convert string to float: F 
$ file Recepten.Dbf
Recepten.Dbf: FoxBase+/dBase III DBF, 1 record * 13734, update-date 115-8-16, codepage ID=0x37, with index file .MDX, at offset 8577 1st record "                                                      FMijn eig"
@olemb
Copy link
Owner

olemb commented Oct 7, 2015

Sorry it's taken me so long reply. I hope you have found a solution in the meantime.

What could the value 'F' mean in a numeric field? Boolean fields often use 'F' for false, but false is not a number.

Could you try to open the file with raw=True and see what sort of values you get in that field?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants