RE: [PHP] having hard time with xls->mysql issues

From: Date: Thu, 21 Dec 2000 20:26:26 +0000
Subject: RE: [PHP] having hard time with xls->mysql issues
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31462@lists.php.net to get a copy of this message
I would suggest creating a copy of your XLS copy and then highlight the column/cells which you need to format the date, the Right Click and select "Format Cells..." and select "Custom" from the list and enter "yyyy-mm-dd" and it should convert those 24.02 dates to 2001-02-24. Next to export the database select "File->Save As..." then where it says "Save as type:" select "Text (Tab Delimitated)" and then select the options you want (tab delimitated is probably the easiest) and it will spit out a .txt file with your records in it... Then just copy it to your server and login to mysql (mysql -u youruser -p databasename) then run the following query "LOAD DATA LOCAL INFILE /path/to/file.txt INTO table name" I believe that's the correct statement but I could be wrong... -Jonathan Sharp Director of Technology - Imprev Inc. Renwick Development Group - Flyerware http://www.flyerware.com/ Phone: (425)688-9200 -----Original Message----- From: Siim Einfeldt aka Itpunk [mailto:siim_e@pshg.edu.ee] Sent: Thursday, December 21, 2000 12:10 PM To: php-general@lists.php.net Subject: [PHP] having hard time with xls->mysql issues I need to convert an .xls(Excel) file into a database table. I have one xls file with about 20-30 sheets, in every sheet I have about up to 150 rows of text which I need to write to the database. (1) On row one (covering 5-6 columns) I have the hotel name (2) Starting from the 6th row I have 4 columns which are important to me(ABCD): L-P 24.02 16.02 15 dbl <-- this is what type of stuff is written to the cols:-) Or actually the first one isn´t that important, but the other ones are. The second and third columns should go to different columns in mysql as well, the fourth column should be split up into two pieces, the first piece, the number(15 in this case) should go to one column and the other part (dbl in this case) should be written to another column. The second and third column, these are dates, which will have to be written to the database in the *right* way. EG: 24.02 should be coverted to 2001-02-24 before inserting to the database. And all the other dates the exact same way and year is 2001 everywhere. The database table itself could look something like this: id hotelname firstdate seconddate number type primary key + some additional fields which I will add later:-) Please, if anyone could give me some advice or direct me to some code, I`d really appreciate it. I promised to get my project done by 24. dec and this missing 'module' is slowing my work down quite much. Thank you in advance, Siim Einfeldt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#31462) next »