[Tutor] Trying to read dBase files
Alan Gauld
alan.gauld at btinternet.com
Tue Mar 11 20:18:54 CET 2014
On 11/03/14 18:39, Al Bull wrote:
> I'm new to python and want to use it to create an application to read one or
> more dbase files, manipulate some data, and create a new file.
You could also try the Dabo project, it is an IDE for building DBase
like apps. I think it supports reading Foxpro(aka DBASE) files.
> I am using Python 3.3. I did some google searches and found something
> called dbfpy to read dbase, so I downloaded and installed it.
>
> File "C:\Python33\lib\site-packages\dbfpy\dbf.py", line 260
> print repr(_rec)
> ^
> SyntaxError: invalid syntax
You are using Python 3.3 so print is a function.
You need to use
print( repr(_rec) )
> My assumption is that this module is written for an earlier release of
> Python?
That may be true too, but your problem is in the print line.
> Some other google searches suggested using microsofts ODBC drivers for
> dBase, so I downloaded and installed pyodbc and got this:
Yes thats possible too if you are on a Windows platform.
> Python 3.3.4 (v3.3.4:7ff62415e426, Feb 10 2014, 18:12:08) [MSC v.1600 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
>>>> import pyodbc
>>>> cnxn = pyodbc.connect('DRIVER={Microsoft Access dBASE
> Driver};SERVER=localhost;DATABASE={Q:\TWS\MAILMERGE\BIL00008.DBF}')
> Traceback (most recent call last):
> ...
> Do I have the driver name incorrect?
Sorry can't help with that one!
HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list