<?php include_once ("../inc/config.inc.php") ?>
<?php
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	
	$handle = fopen("/srv/www/htdocs/maint/admin/insee_cp_corse.csv","r");
	while (!feof($handle)) 
	{
		$buffer = fgets($handle, 4096);
		echo $buffer." : ";
		$champs = explode(";", $buffer);
		for($i=0; $i <3; $i++) 
		{
			$champs[$i] = trim(ereg_replace('"', '', $champs[$i]));
		}
		$rech = "INSERT INTO `smi_villes`";
		$rech .= " (villes_insee,villes_cp,villes_nom) VALUES";
		$rech .= " ('$champs[0]','$champs[1]','$champs[2]')";
		$rs = mysql_query($rech) or die(mysql_error());
		echo "importé<br>";
		
	}
	fclose($handle);
	
	mysql_close($conn);
	
	echo "Terminé";
?>
