1

我已经尝试过使用带有 dbase 扩展的 PHP 5.3,但是对于超过 2 GB 的大型数据库,它不能可靠地工作。我需要一种方法来遍历大型 DBF 的一个子部分并能够读取/编辑字段。可以这样做(我使用 Windows)吗?

第一次尝试:

table = dbf.Table('myhugeDBF.dbf') 
#is this the only way to access the dbf data? 
#I only need the last 10k records as opposed to the whole 4.5 GB beast


table.open()

for i in xrange(len(table)-10000, len(table)):
    table[i].desc = (table[i].desc).replace("\n","")
    print "*" + str(table[i].desc) + "*" #for debug purposes
4

1 回答 1

1
table = dbf.Table('myhugeDBF.dbf') 
# is this the only way to access the dbf data?
# yes.  the above only reads the header, though, so you can get basic
# info about the dbf (size, field names, etc.)


table.open()
# this creates a data structure with one (small) element per record

for record in table[-10000:]:
    with record:
        record.desc = record.desc.replace('\n','')
于 2013-08-15T17:00:02.027 回答