我已经尝试将PHP 5.3与dbase扩展一起使用,但对于超过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
答案 0 :(得分: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','')