Reading Dbase files 
Author Message
 Reading Dbase files

I am trying to read .dbf files using the (old) dbf.py module (version 0.2
1999/11/12 written
by Michal Spalinski. This seemed to work quite well, untill I found out that
records which apparantly
have been deleted are also read as 'normal'...
In other words: not really useable or at least not compatible with this
format of .dbf files.

I am looking for advise how to proceed. I really need this functionality and
should like to keep on using Python.

Thanks, Leo



Thu, 28 Oct 2004 20:02:43 GMT  
 Reading Dbase files
how about trying ADO with this DSN-Less connection?

Driver={Microsoft dBASE Driver
(*.dbf)};DriverID=277;Dbq=c:\somepath\dbname.dbf;

See http://www.e-coli.net/pyado.html for details.

-d


Quote:
> I am trying to read .dbf files using the (old) dbf.py module (version 0.2
> 1999/11/12 written
> by Michal Spalinski. This seemed to work quite well, untill I found out
that
> records which apparantly
> have been deleted are also read as 'normal'...
> In other words: not really useable or at least not compatible with this
> format of .dbf files.

> I am looking for advise how to proceed. I really need this functionality
and
> should like to keep on using Python.

> Thanks, Leo



Fri, 29 Oct 2004 00:25:20 GMT  
 Reading Dbase files

Quote:

> I am trying to read .dbf files using the (old) dbf.py module
> (version 0.2 1999/11/12 written
> by Michal Spalinski. This seemed to work quite well, untill I
> found out that records which apparantly
> have been deleted are also read as 'normal'...
> In other words: not really useable or at least not compatible with
> this format of .dbf files.

> I am looking for advise how to proceed. I really need this
> functionality and should like to keep on using Python.

I'm not familiar with dbf.py, but old dBase programs don't physically
delete the record (not right away, anyway) but set a marker in a
special field to indicate their deleted status. I presume there's some
way in which this marker can be tested in dbf.py, and if not it
shouldn't be terribly hard to add this. The dBase file format is well
documented over the years.

Alternatives:
- under Windows you can use ODBC datasource manager in the control
panel to setup a dBase datasource, after which you can use ODBC to get
at your data.

- Wrap a dBase library like Xbase for use under Python.

Robert Amesz



Fri, 29 Oct 2004 06:40:03 GMT  
 Reading Dbase files

Quote:


> > I am trying to read .dbf files using the (old) dbf.py module
> > (version 0.2 1999/11/12 written
> > by Michal Spalinski. This seemed to work quite well, untill I
> > found out that records which apparantly
> > have been deleted are also read as 'normal'...

How did you find out? What do the apparently-deleted records look
like? Rhetorical question, answer supplied below, I'm just eternally
curious about
the way humans diagnose problems :-)

Quote:
> > In other words: not really useable or at least not compatible with
> > this format of .dbf files.

> > I am looking for advise how to proceed. I really need this
> > functionality and should like to keep on using Python.

> I'm not familiar with dbf.py, but old dBase programs don't physically
> delete the record (not right away, anyway) but set a marker in a
> special field to indicate their deleted status. I presume there's some
> way in which this marker can be tested in dbf.py, and if not it
> shouldn't be terribly hard to add this. The dBase file format is well
> documented over the years.

Here is the relevant part from dbf.py:

    def __getitem__(self, recno):
        if recno < 0 or recno >= self.nrecs:
            raise IndexError
        else:
            raw = self._get(recno)

A deleted record will satisfy raw[0] == '*'

Here is one of the places where you discover such knowledge:

    http://www.wotsit.org/

You might want to add a sequential-reading method to the dbf class, as
well as or instead of hacking in raising a DeletedRecordError (or
somesuch) exception in the __getitem__ method. You may even be
interested in recovering the deleted records after a disaster. If
fiddling with dbf.py along those lines is not your territory, e-mail
me -- I have such a sequentially-reading gadget written circa 1999; it
will even run with python 1.5.2.

HTH,

John



Fri, 29 Oct 2004 11:40:55 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. APL reading dBase files

2. Reading DBASE files

3. Unable to read dbf file as dbase file

4. Read from a dBase.IV file

5. Reading text file into DBase?

6. dbase-file/clipper-index read-module

7. TCL proc for reading/writing Xbase (dBase) files?

8. Converting dBase III to dBase IV files ?

9. convert DAT-files to DBase-files

10. Need old file-dbase 1.0 help file?

11. need to convert a DAT file on cobol a DBF file on dbase

12. To everyone : Visual dbase 7.5 or dBase 2000 SHIT OR OK

 

 
Powered by phpBB® Forum Software