set_encoding('latin1'); while (($data = fgetcsv($handle, 2000,"!")) !== FALSE) { $num = count($data); for ($c=0; $c < $num; $c++) { // skip the first line if ( $line < 1 ) continue; //----------------------------------------------------- // Parsing CSV comes here //----------------------------------------------------- $row=explode(';',$data[$c]); if ( sizeof ($row) < 7 ) continue; // Your own bank account $compte_ordre=''; // Execution date of the operation $date_exec=str_replace('/','-',$row[0]); // Operation reference, it must be unique, so we take the datum // the line number and a random number $r=rand(1,1000); $code=$date_exec.'-'.$line.$r; // Effective date of the operation $date_val=str_replace('/','-',$row[1]); // Third party bank account $num_compte=$row[2]; // $detail=trim($row[3]); // $signe=trim($row[4]); // // remove first the thousand sep. $montant=str_replace('.','',$row[5]); // replace the coma by a period $montant=str_replace(',','.',$montant); // remove the sign //$montant=str_replace('+','',$montant); // use the sign if ($signe == '-') $montant='-'.$montant; // Curency used $devise=trim($row[6]); //---------------------------------------------------- // Skip dubbel impossible //---------------------------------------------------- echo "Ajout de $detail"; echo "
"; //----------------------------------------------------- // insert into import_tmp //----------------------------------------------------- $Sql="insert into import_tmp (code, date_exec , date_valeur, montant, devise, num_compte, detail, bq_account , jrn, status) values ('$code', to_date('$date_exec','DD-MM-YYYY'), to_date('$date_exec','DD-MM-YYYY'), $montant, '$devise', '".$num_compte."', '".addslashes($detail)." ', '$p_bq_account', $p_jrn, 'n')"; try { $p_cn->exec_sql($Sql); } catch(Exception $e) { echo(__FILE__.":".__LINE__." Erreur : ".$e->getCode()." msg ".$e->getMessage()); rollback($p_cn); break; } } // for ($c=0;$c<$num;$c++) $line++; } // file is read fclose($handle); commit($p_cn); ?>