By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,679 Members | 1,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,679 IT Pros & Developers. It's quick & easy.

Converting a .dbf file to a CSV file

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

Johanna Pfalz

Nov 2 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Johanna Pfalz wrote:
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.


Nov 2 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.