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

2018-01-23 14:37:26 +08:00
 OneDayTwoApple
使用 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)

求各位大神解答。
2335 次点击
所在节点    Python
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/425240

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX