title: How to convert dbf to csv in python 3.6.9?
body: <p>I have large amount of .dbf data (around 1gb each) and I need to convert it to .csv in order to use in my actuarial tool. I've found a code which works with python 2 (my friend tried and managed to produce dummy.csv). I have to use 3.6.9 (workplace uses 3.6.9) but can't make it run in that version.</p>
  <p>I'm very new at python so any help is much appreciated. thank you very much !</p>
  <pre><code>import csv 
  from dbfpy import dbf 
  import os
  import sys
  
  filename = 'DUMMY.dbf'
  if filename.endswith('.dbf'):
    print (&quot;Converting %s to csv&quot; % filename)
    csv_fn = filename[:-4]+ &quot;.csv&quot;
    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 (&quot;Done...&quot;)
  else:
    print (&quot;Filename does not end with .dbf&quot;)
    
  </code></pre>
  <p>of course, sorry, forgot the error.</p>
  <pre><code>   Traceback (most recent call last):
  
    File &quot;/opt/anaconda/envs/env_python/lib/python3.6/site-packages/IPython/core/interactiveshell.py&quot;, line 3326, in run_code
      exec(code_obj, self.user_global_ns, self.user_ns)
  
    File &quot;&lt;ipython-input-4-11540611f260&gt;&quot;, line 2, in &lt;module&gt;
      from dbfpy import dbf
  
    File &quot;/opt/anaconda/envs/env_python/lib/python3.6/site-packages/dbfpy/dbf.py&quot;, line 280
      print repr(_rec)
               ^
  SyntaxError: invalid syntax
  </code></pre>