Page 1 of 1
php4dbf - CSV-import
Posted: Tue Nov 26, 2024 8:54 pm
by Otto
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
Re: php4dbf - CSV-import
Posted: Wed Nov 27, 2024 9:43 am
by Marc Venken
Is this a stand alone project ?
If you use a local path... it will also work ?
Re: php4dbf - CSV-import
Posted: Wed Nov 27, 2024 10:33 am
by Otto
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
Re: php4dbf - CSV-import
Posted: Wed Nov 27, 2024 10:45 am
by Marc Venken
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.
Re: php4dbf - CSV-import
Posted: Wed Nov 27, 2024 5:43 pm
by Otto
Hello Marc,
I have sent the link to the program for importing CSV into DBF files via email.
Best regards,
Otto
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 8:53 am
by Otto
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.
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 10:24 am
by Marc Venken
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.
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 12:59 pm
by Otto
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
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 1:13 pm
by Marc Venken
Changed to 8.40. Have to look where to put the correct path, but I see the program
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 3:07 pm
by Otto
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.
Re: php4dbf - CSV-import
Posted: Fri Nov 29, 2024 9:43 pm
by Otto
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