简体   繁体   中英

Unicode Error when trying to convert DBF to CSV

I'm in the process of converting really old data from years ago. The DBF won't convert into a CSV file, which I need because I will eventually use the data in SQL

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa5 in position 4: invalid start byte

My full code here:

import dbf
import simpledbf
from simpledbf import Dbf5


db = Dbf5('CREDIT.dbf')

db.to_csv('test.csv')

It looks simpledbf accepts an encoding in its constructor. Try:

db = Dbf5('CREDIT.dbf', codec="cp1252")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM