title: DBF - encoding cp1250
body: <p>I have dbf database encoded in cp1250 and I am reading this database using folowing code:</p>
  
  <pre><code>import csv
  from dbfpy import dbf
  import os
  import sys
  
  filename = sys.argv[1]
  if filename.endswith('.dbf'):
      print "Converting %s to csv" % filename
      csv_fn = filename[:-4]+ ".csv"
      with open(csv_fn,'wb') as csvfile:
          in_db = dbf.Dbf(filename)
          out_csv = csv.writer(csvfile)
          names = []
          for field in in_db.header.fields:
              names.append(field.name)
          #out_csv.writerow(names)
          for rec in in_db:
              out_csv.writerow(rec.fieldData)
          in_db.close()
          print "Done..."
  else:
    print "Filename does not end with .dbf"
  </code></pre>
  
  <p>Problem is, that final csv file is wrong. Encoding of the file is ANSI and some characters are corrupted. I would like to ask you, if you can help me how to read dbf file correctly.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>I tried different code from <a href="https://pypi.python.org/pypi/simpledbf/0.2.4" rel="nofollow">https://pypi.python.org/pypi/simpledbf/0.2.4</a>, there is some error.</p>
  
  <p>Source 2:</p>
  
  <pre><code>from simpledbf import Dbf5
  import os
  import sys
  
  dbf = Dbf5('test.dbf', codec='cp1250');
  dbf.to_csv('junk.csv');
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>python program2.py
  Traceback (most recent call last):
    File "program2.py", line 5, in &lt;module&gt;
      dbf = Dbf5('test.dbf', codec='cp1250');
    File "D:\ProgramFiles\Anaconda\lib\site-packages\simpledbf\simpledbf.py",      line 557, in __init__
      assert terminator == b'\r'
  </code></pre>
  
  <p>AssertionError</p>
  
  <p>I really don't know how to solve this problem.</p>