dbf file
Posted: Mon Jun 19, 2006 7:18 pm
I've got a .dbf file (foxpro, I believe) that I would like to read. The file is part of another application that updates it once in a while, ie: it is not static, it gets changed and must be read every other day or so.
I want to be able to open the file and import it to a mysql database, updating the mysql table on a regular basis.
The problem: I tried the following code
But, I get the error (as you might expect) "Could not open dbf file." I've tried using PHP to create and then read a test dbf file and that works fine, so I think there is a problem with the file. The file is in the proper location and is accessible (it's in the same folder as the test dbf file.)
The program DBFview shows me this info about the file:
I noticed another post on this forum that talked about the wrong version of dbf file and I'm hoping that this is not the case for me. Other than contacting the developer is there anyway to find out? Does anybody have any other suggestions?
BTW: I can't just use something like dbfviewer to produce the sql to insert it into a mysql table, because the file is "live" being changed daily by another application.
BBTW: the contacts.dbf file I'm testing on, is NOT live -- it has been copied to another directory so I can play with it, without damaging the original.
My Setup:
Apache2
PHP5 (with php_dbase.dll)
win xp
I'm thinking, perhaps there might be a way to treat this as a flat text file that I can extract rows from. Not sure, I'll have to play with it.
If I left anything out, ask me..... and thanks in advance.
I want to be able to open the file and import it to a mysql database, updating the mysql table on a regular basis.
The problem: I tried the following code
Code: Select all
$id = @dbase_open("contacts.dbf", 0)
or die ("Could not open dbf file.");
$record = dbase_get_record($id, 955);The program DBFview shows me this info about the file:
Code: Select all
C:\www\contacts\contacts.dbf
File size (bytes): 1793394
Version: FoxPro with memo, index present
Number of records: 9640
N Field name Type Width
---------------------------------
1 ID Numeric 10
2 LINKID Numeric 10
3 FNAME Character 24
4 LNAME Character 24
5 COMPANY Character 48
6 COMPID Character 8
7 OCUPATION Character 16
8 POSITION Character 16
9 LASTUPDATE Float 19.9
10 TEXTBLOB Memo 10
---------------------------------
Total: 186BTW: I can't just use something like dbfviewer to produce the sql to insert it into a mysql table, because the file is "live" being changed daily by another application.
BBTW: the contacts.dbf file I'm testing on, is NOT live -- it has been copied to another directory so I can play with it, without damaging the original.
My Setup:
Apache2
PHP5 (with php_dbase.dll)
win xp
I'm thinking, perhaps there might be a way to treat this as a flat text file that I can extract rows from. Not sure, I'll have to play with it.
If I left anything out, ask me..... and thanks in advance.