obyno Posted September 21, 2006 Share Posted September 21, 2006 I am trying to read the contents of a forty megabyte text file that was saved as a Tab delimited file from MS Excel. The intention is to insert the columns within into a MySQL table. The trouble is that the maximum times in minutes which a file can be executed before php gives up is not long enough to compare with the lenth of time thi is taking. Can somebody please suggest to me how I might accomplish this? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/21525-parsing-a-large-file-and-inserting-content-into-mysql/ Share on other sites More sharing options...
redarrow Posted September 21, 2006 Share Posted September 21, 2006 increase your time out in the php.ini.good luck. Quote Link to comment https://forums.phpfreaks.com/topic/21525-parsing-a-large-file-and-inserting-content-into-mysql/#findComment-96029 Share on other sites More sharing options...
obyno Posted September 21, 2006 Author Share Posted September 21, 2006 I am hosted on a public server where I have no access to the php.ini. I dont think the Administrators would take kindly to any such requests from me. Thanks though. Quote Link to comment https://forums.phpfreaks.com/topic/21525-parsing-a-large-file-and-inserting-content-into-mysql/#findComment-96045 Share on other sites More sharing options...
printf Posted September 21, 2006 Share Posted September 21, 2006 Have a look at [url=http://dev.mysql.com/doc/refman/5.0/en/load-data.html]LOAD DATA INFILE[/url]Simple example...[code=php:0]<? define ( 'DB_HOST', 'localhost:3306' ); // should not need to change define ( 'DB_USER', 'user' ); // enter the user name for this database define ( 'DB_PASS', 'pass' ); // enter the password for this database define ( 'DB_NAME', 'my_db' ); // enter the database name you are connecting to define ( 'DB_TABLE', 'my_table' ); // enter the NAME of the database TABLE to INSERT data into define ( 'DBF_CSVP', './path_to/csv.txt' ); // enter the PATH and NAME of the CSV FILE to IMPORT mysql_connect ( DB_HOST, DB_USER, DB_PASS ) or die ( 'Connection Error: ' . mysql_error () ); mysql_select_db ( DB_NAME ) or die ( 'Select DB (' . DB_NAME . ') Error: ' . mysql_error () ); mysql_query ( "LOAD DATA INFILE '" . DBF_CSVP . "' INTO TABLE " . DB_TABLE . " FIELDS TERMINATED BY '\\t\\t' OPTIONALLY ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\\r\\n'" );?>[/code]me Quote Link to comment https://forums.phpfreaks.com/topic/21525-parsing-a-large-file-and-inserting-content-into-mysql/#findComment-96084 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.