FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour php4dbf - CSV-import
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
php4dbf - CSV-import
Posted: Tue Nov 26, 2024 08:54 PM
Hello friends,

Sometimes it is also necessary to access DBF files from PHP. Therefore, I created a library.

Here is an example today of how I import a CSV file into a DBF file.

The program is designed to streamline the process of transferring structured data (like customer information) from a CSV file into a DBF database file. It provides a user-friendly interface for mapping paths and verifying data before the import.

Best regards,
Otto

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: php4dbf - CSV-import
Posted: Wed Nov 27, 2024 09:43 AM

Is this a stand alone project ?

If you use a local path... it will also work ?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: php4dbf - CSV-import
Posted: Wed Nov 27, 2024 10:33 AM

Hello Marc,

Do you have access to a PHP server where you can upload a file and then execute it?

It also works on localhost if PHP is installed.

If so, I can email you the project.

It's very simple:

copy importcsv.php and php4dbf.

You would then need to create the subdirectory "import" for your CSV and the "data" directory for your DBF.

Best regards,

Otto

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: php4dbf - CSV-import
Posted: Wed Nov 27, 2024 10:45 AM

I have the options yes.

I can upload and try.

Interested because I use a lot of csv (now in combination with exel and FW function) to read data and convert into a dbf for processing.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: php4dbf - CSV-import
Posted: Wed Nov 27, 2024 05:43 PM

Hello Marc,

I have sent the link to the program for importing CSV into DBF files via email.

Best regards,

Otto

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 08:53 AM
Extended version of your program that allows assigning either a CSV field or a fixed text for each DBF field. If a fixed text is entered, it will be used; otherwise, the field will be filled from the CSV file.



Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 10:24 AM

I sent a error that I get by mail in order to be shure it is not at my side .... and the FW group get confused.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 12:59 PM

Hello Marc,

I am using PHP version 8.3.9.

In PHP versions prior to 8.0, it is not allowed to set a default value other than NULL for parameters with type hints. This leads to the mentioned error.

I think that's the problem.

Best regards,

Otto

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 01:13 PM

Changed to 8.40. Have to look where to put the correct path, but I see the program

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 03:07 PM

Good to hear. Files outside the directory C:\htdocs are blocked. This is a security measure to prevent someone from accessing files outside the webserver. However, you can change this setting if you want and if it's your system.

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 09:43 PM

Marc, The program needs the correct DOS path.

Where did you host your web server? On your PC or with a hosting company?

Maybe I should implement a file upload for the DBF file in case there is no direct access to the web server.

Best regards,

Otto

Continue the discussion