Text from Excel csv file loaded into MySQL table
| From: | Alan Milnes | Date: | Mon, 16 Oct 2006 15:40:55 +0000 |
| Subject: | Text from Excel csv file loaded into MySQL table | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-243186@lists.php.net to get a copy of this message | ||
Can anyone point me to a really good end to end tutorial on extracting text from an Excel csv file and uploading it into MySQL via a PHP script? There are lots of bits and pieces on the Web and in the PHP manual but I haven't found a really comprehensive article yet. I have Welling and Thomson's book but again it's not detailed enough.
I've got a script at the moment which works fine with known values (generated by a program I own) but I now need to cater for files prepared by other people which may have all sorts of characters in them.
A typical line of text may look something like this:-
123456,999999,Computer Systems,Desktops/Towers,HP,DX6100M,DX6100M,"127 SHAWAK HARBAN, DUCK'S POINT",MUMBAI
I think I need to do something like this:-
Open the file
Get the current line
Convert it to an array (making sure I handle any commas etc in the user text)
Map the array to the MySQL fields
Upload it to the database, escaping as appropriate
Continue until all lines have been read.
I know I'm not the first person to have had to do this but can't find exactly what I'm looking for.
Thanks
Alan