0

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')
  • 1
    Where does the error occur? On the `to_csv` line? It's possible the `simpledbf` module is very old (like Python 2), and isn't thinking about character sets. You may need to modify the module. dbf files are probably in CP-1252 (where 0xA5 is the Japanese yen symbol). – Tim Roberts Jul 27 '21 at 20:50
  • Does this answer your question? [UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 35: invalid start byte](https://stackoverflow.com/questions/45529507/unicodedecodeerror-utf-8-codec-cant-decode-byte-0x96-in-position-35-invalid) – Ulrich Eckhardt Jul 27 '21 at 21:17
  • Please search for the error message online first! As a new user here, also take the [tour] and read [ask]. – Ulrich Eckhardt Jul 27 '21 at 21:17

1 Answers1

0

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

db = Dbf5('CREDIT.dbf', codec="cp1252")
Tim Roberts
  • 48,973
  • 4
  • 21
  • 30