Converting a .dbf file to a CSV file

J

Johanna Pfalz

Is there a module/method in python to convert a file from .DBF format to
..CSV format?

Johanna Pfalz
 
J

John Machin

Johanna said:
Is there a module/method in python to convert a file from .DBF format to
.CSV format?

Hi Johanna, the best start at the moment is the Python Cookbook recipe
that others have quoted. Steps:

(1) Input: as per recipe. Note that the recipe handles only the
earliest simplest form of dbf files; you may have data types other than
C, N, D and L. Note that there are myriads of third-party dbf writing
codes out there, and some of them are a little idiosyncratic. I am in
the pre-alpha stage of producing a module whose intent is to read just
about everything it is given, with lots of assertions, error checks,
and warnings. This includes M (memo) fields which are stored in a
separate file in 1 of at least 3 formats. If your file causes the
recipe to crashes or produce incorrect results, there is a good chance
that I may be able to help you.
(2) [optional] derive output file headings from names of fields.
(3) Convert data values to str, if str(input_value) is not appropriate
(4) Write values to csv file. For this I strongly suggest that you use
the Python csv module, rather than attempting to reinvent the wheel
(and the often-forgotten axle). If, as I guess from your name, that you
want the delimiter to be ";" instead of ",", then that can be handled
easily with ..., delimiter=";" in the call to csv.writer.

HTH,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top