php4dbf - CSV-import

php4dbf - CSV-import

Postby Otto » Tue Nov 26, 2024 8: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

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: php4dbf - CSV-import

Postby Marc Venken » Wed Nov 27, 2024 9:43 am

Is this a stand alone project ?
If you use a local path... it will also work ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: php4dbf - CSV-import

Postby Otto » 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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: php4dbf - CSV-import

Postby Marc Venken » 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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: php4dbf - CSV-import

Postby Otto » Wed Nov 27, 2024 5:43 pm

Hello Marc,
I have sent the link to the program for importing CSV into DBF files via email.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: php4dbf - CSV-import

Postby Otto » Fri Nov 29, 2024 8: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.

Image

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: php4dbf - CSV-import

Postby Marc Venken » 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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: php4dbf - CSV-import

Postby Otto » 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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: php4dbf - CSV-import

Postby Marc Venken » Fri Nov 29, 2024 1: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: php4dbf - CSV-import

Postby Otto » Fri Nov 29, 2024 3: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.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: php4dbf - CSV-import

Postby Otto » Fri Nov 29, 2024 9: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests