V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
OneDayTwoApple
V2EX  ›  Python

请教 Python 如何解析 DBF 文件, SJSHQ.dbf 上交所行情文件,数据来源于巨灵数据。

  •  1
     
  •   OneDayTwoApple · 2018-01-23 14:37:26 +08:00 · 2335 次点击
    这是一个创建于 2503 天前的主题,其中的信息可能已经有所发展或是发生改变。
    使用 dbf, dbfread,simpledbf 均报错。
    b = dbfread.read('SJSXX.dbf', 'gb2312')
    File "/home/zhangyunfang/pymongo_py3/lib/python3.6/site-packages/dbfread/deprecated_dbf.py", line 49, in read
    return DeprecatedDBF(filename, load=True, **kwargs)
    File "/home/zhangyunfang/pymongo_py3/lib/python3.6/site-packages/dbfread/dbf.py", line 136, in __init__
    self.load()
    File "/home/zhangyunfang/pymongo_py3/lib/python3.6/site-packages/dbfread/deprecated_dbf.py", line 18, in load
    self[:] = self._iter_records(b' ')
    File "/home/zhangyunfang/pymongo_py3/lib/python3.6/site-packages/dbfread/dbf.py", line 316, in _iter_records
    for field in self.fields]
    File "/home/zhangyunfang/pymongo_py3/lib/python3.6/site-packages/dbfread/dbf.py", line 316, in <listcomp>
    for field in self.fields]
    File "/home/zhangyunfang/pymongo_py3/lib/python3.6/site-packages/dbfread/field_parser.py", line 79, in parse
    return func(field, data)
    File "/home/zhangyunfang/pymongo_py3/lib/python3.6/site-packages/dbfread/field_parser.py", line 87, in parseC
    return self.decode_text(data.rstrip(b'\0 '))
    File "/home/zhangyunfang/pymongo_py3/lib/python3.6/site-packages/dbfread/field_parser.py", line 45, in decode_text
    return decode_text(text, self.encoding, errors=self.char_decode_errors)
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc9 in position 0: ordinal not in range(128)

    求各位大神解答。
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2826 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 19ms · UTC 06:53 · PVG 14:53 · LAX 22:53 · JFK 01:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.