winmastergames Posted June 7, 2008 Share Posted June 7, 2008 Well Ive got this code: <?php mysql_connect("localhost", "root", "pass"); mysql_select_db("webmeterreadgrid"); # first get a mysql connection as per the FAQ $fcontents = file ('./206011569-6.ls2'); # expects the csv file to be in the same dir as this script for($i=0; $i<sizeof($fcontents); $i++) { $line = trim($fcontents[$i]); $arr = explode("\t", $line); #if your data is comma separated # instead of tab separated, # change the '\t' above to ',' $sql = "insert into coredatatest values ('". implode("','", $arr) ."')"; mysql_query($sql); echo $sql ."<br>\n"; if(mysql_error()) { echo mysql_error() ."<br>\n"; } } ?> And Is there any way to make this code Start from a certain line like line: 7 so it starts the process on the file on line 7 so it doesnt read any data on line 1,2,3,4,5,6 Thanks Quote Link to comment Share on other sites More sharing options...
sasa Posted June 7, 2008 Share Posted June 7, 2008 change to # expects the csv file to be in the same dir as this script $skip_first_n_lines = 6; for($i=$skip_first_n_lines; $i<sizeof($fcontents); $i++) { etc. Quote Link to comment Share on other sites More sharing options...
winmastergames Posted June 7, 2008 Author Share Posted June 7, 2008 Thanks Alot Quote Link to comment 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.