Инфа от клиента: У нас почему-то крон таски очень долго отрабатываются.
Смотрим в крон файл.
Плачем.
[POSTS]
[/POSTS]
Смотрим в крон файл.
Плачем.
[POSTS]
PHP:
<?php
ini_set("max_execution_time","-1");
ini_set('memory_limit', '-1');
/**
* @file
* Cron API for JOB CSV VSCOMREF IMPORT
*/
//require_once (drupal_get_path('module', 'webcatalog').'/inc/config.inc');
/**
* Implements hook_cron().
*
* hook_cron() is the traditional (pre-Drupal 7) hook for doing "background"
* processing. It gets called every time the Drupal cron runs and must decide
* what it will do.
*/
function webcatalog_vscomref_cron() {
$today = date("Ymd");
/*
if (isset($_SERVER['DOCUMENT_ROOT'])) {
$document_root = $_SERVER['DOCUMENT_ROOT'];
} else if ($_SERVER['DOCUMENT_ROOT'] == "") {
$document_root = preg_replace('#sites\/all\/modules\/project\/webcatalog$#', '$1', dirname(__DIR__));
} else {
$document_root = "/space/www/projectservice/data/current";
}
*/
$document_root = _get_document_root();
//$document_root = $_SERVER['DOCUMENT_ROOT'];
$divisions = _list_division();
foreach ($divisions as $divis) {
$div_upper = strtoupper($divis);
$div_lower = strtolower($divis);
$file = $document_root."/sites/all/modules/project/webcatalog/import/files/vscomref/FICHIER_EXALEAD_VSCOMREF_$div_upper.csv";
$LOGS='';
if(is_file($file)) {
// sql to create table
$sql_drop = "DROP TABLE IF EXISTS project_webcat_product_tmp_$div_lower";
$sql = "CREATE TABLE project_webcat_product_tmp_$div_lower (
id_product_project INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
short_vscomref_name VARCHAR(255) NOT NULL,
long_vscomref_name VARCHAR(255) NOT NULL,
vs_ref_replace VARCHAR(255) NOT NULL,
create_date VARCHAR(255) NOT NULL,
last_update_date VARCHAR(255) NOT NULL,
lob_code VARCHAR(255) NOT NULL,
lob_name VARCHAR(255) NOT NULL,
made_in_code VARCHAR(255) NOT NULL,
made_in_en VARCHAR(255) NOT NULL,
made_in_fr VARCHAR(255) NOT NULL,
surcharge_code VARCHAR(255) NOT NULL,
usageref VARCHAR(255) NOT NULL,
dp_family_code VARCHAR(255) NOT NULL,
dp_family_name VARCHAR(255) NOT NULL,
vehicle_cat_code_main VARCHAR(255) NOT NULL,
brand_name VARCHAR(255) NOT NULL,
range_name VARCHAR(255) NOT NULL,
int_sap_status VARCHAR(255) NOT NULL,
int_sap_status_old VARCHAR(255) NOT NULL,
custom_code VARCHAR(255) NOT NULL,
sap_eng_designation VARCHAR(255) NOT NULL,
segment_code VARCHAR(255) NOT NULL,
sene_type_code VARCHAR(255) NOT NULL,
projectrigin_ref VARCHAR(255) NOT NULL,
ean_code VARCHAR(255) NOT NULL,
ktypnr text NOT NULL,
specific_sales_org_code VARCHAR(255) NOT NULL,
product_code VARCHAR(255) NOT NULL,
product_display VARCHAR(255) NOT NULL,
product_family_display VARCHAR(255) NOT NULL,
name_cl_manufacturer VARCHAR(255) NOT NULL,
csu_gross_weight VARCHAR(255) NOT NULL,
csu_nber_item VARCHAR(255) NOT NULL,
gamma VARCHAR(255) NOT NULL,
sub_range VARCHAR(255) NOT NULL,
vehicle_ids text NOT NULL,
vehicle_cat_code_lcv VARCHAR(255) NOT NULL,
vehicle_cat_code_trucks VARCHAR(255) NOT NULL,
vehicle_cat_code_agri VARCHAR(255) NOT NULL,
vehicle_cat_code_const VARCHAR(255) NOT NULL,
vehicle_cat_code_trailer VARCHAR(255) NOT NULL,
vehicle_cat_code_gar VARCHAR(255) NOT NULL,
vehicle_cat_code_marine VARCHAR(255) NOT NULL,
vehicle_cat_code_bus VARCHAR(255) NOT NULL,
INDEX short_vscomref_name (short_vscomref_name),
INDEX long_vscomref_name (long_vscomref_name),
INDEX vehicle_cat_code_main (vehicle_cat_code_main),
INDEX vehicle_cat_code_lcv (vehicle_cat_code_lcv),
INDEX vehicle_cat_code_trucks (vehicle_cat_code_trucks),
INDEX vehicle_cat_code_agri (vehicle_cat_code_agri),
INDEX vehicle_cat_code_const (vehicle_cat_code_const),
INDEX vehicle_cat_code_trailer (vehicle_cat_code_trailer),
INDEX vehicle_cat_code_gar (vehicle_cat_code_gar),
INDEX vehicle_cat_code_marine (vehicle_cat_code_marine),
INDEX vehicle_cat_code_bus (vehicle_cat_code_bus)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
";
if (db_query($sql_drop)) {
if (db_query($sql)) {
$LOGS .= "Table project_webcat_product_tmp_$div_lower créée avec succès. </br>";
} else {
$LOGS .= "Error creating table.";
}
}else{
$LOGS .= "Error creating table: Table 'project_webcat_product_tmp_$div_lower' existe déjà. </br>";
}
}
$check_entetes_exalead=array('SHORT_VSCOMREF_NAME', 'LONG_VSCOMREF_NAME', 'VS_REF_REPLACE', 'CREATE_DATE', 'LAST_UPDATE_DATE', 'LOB_CODE', 'LOB_NAME', 'MADE_IN_CODE', 'MADE_IN_EN', 'MADE_IN_FR' , 'SURCHARGE_CODE' , 'USAGEREF' , 'DP_FAMILY_CODE' , 'DP_FAMILY_NAME' , 'VEHICLE_CAT_CODE_MAIN' , 'BRAND_NAME' , 'RANGE_NAME' , 'INT_SAP_STATUS' , 'INT_SAP_STATUS_OLD' , 'CUSTOM_CODE' , 'SAP_ENG_DESIGNATION' , 'SEGMENT_CODE' , 'SENE_TYPE_CODE' , 'PROJECTRIGIN_REF' , 'EAN_CODE' , 'KTYPNR' , 'SPECIFIC_SALES_ORG_CODE' , 'PRODUCT_CODE' , 'PRODUCT_DISPLAY' , 'PRODUCT_FAMILY_DISPLAY' , 'NAME_CL_MANUFACTURER', 'CSU_GROSS_WEIGHT', 'CSU_NBER_ITEM', 'GAMMA', 'SUB_RANGE', 'VEHICLE_IDS', 'VEHICLE_CAT_CODE_LCV', 'VEHICLE_CAT_CODE_TRUCKS', 'VEHICLE_CAT_CODE_AGRI', 'VEHICLE_CAT_CODE_CONST', 'VEHICLE_CAT_CODE_TRAILER', 'VEHICLE_CAT_CODE_GAR', 'VEHICLE_CAT_CODE_MARINE', 'VEHICLE_CAT_CODE_BUS');
$log_file = 'import-exalead-vscomref-'.$div_upper.'-'.date('Y-m-d-H:i:s').'.log.txt';
$tab_req = array();
$LOGS .= 'Début script : '.date('Y-m-d H:i:s', time())."\n\n";
$list_modes=array(/*'check'*/);
$mode = 'import';
$dh_last_maj = '---------- --:--:--';
$LOGS .= 'Dernière mise à jour effectuée le '.$dh_last_maj."\n";
//Vérification que les fichiers ont été modifiés depuis la dernière mise à jour (sinon, pas de mise à jour)
$maj_needed=false;
if( (is_file($file)) && (filesize($file) > 0) ) {
$finfo = stat($file);
$last_mod = date('Y-m-d H:i:s',$finfo[9]);
if($last_mod>=$dh_last_maj) $maj_needed=true;
}
if(!$maj_needed) {
$LOGS .= 'Les fichiers n\'ont pas été mis à jour depuis le dernier import > pas de traitement.'."\n\n";
}
$LOGS .= 'Début import des fichiers : '.date('Y-m-d H:i:s', time())."\n";
$LOGS .= '----------------------------------------------------------------'."\n";
$flag_error=false;
/******************* LECTURE (et éventuel TRAITEMENT) DES FICHIERS ***********************/
//Parcours du fichier VSCOMREF
$LOGS .= 'Fichier '.$file."\n";
if( (is_file($file)) && (filesize($file) > 0) ) {
$handle = fopen($file, "r");
$num_ligne=0;
$num_ligne_ok=0;
while (($csv_datas = fgetcsv($handle, 0, ";", '"')) !== false) {
$num_ligne++;
//Conversion des données (Encodage UTF-8)
$csv_datas = _conversion_csv_data();
if($num_ligne==1) {
$entetes=$csv_datas;
if($entetes!=$check_entetes_exalead) {
unset($entetes);
$LOGS .= 'Erreur FATALE : colonnes d\'en-têtes incorrectes'."\n";
$flag_error=true;
break;
}
} else {
if($num_ligne%1000 == 0) $LOGS .= $num_ligne.') ';
//Lecture des données
if(!($datas = @array_combine($entetes, $csv_datas))) {
$LOGS .= '- Erreur ligne '.$num_ligne.' > nombre de champs incorrects'."\n";
$flag_error=true;
continue;
}
if($mode=='import') {
try{
db_insert('project_webcat_product_tmp_'.$div_lower)
->fields(array(
'short_vscomref_name' => $datas['SHORT_VSCOMREF_NAME'],
'long_vscomref_name' => $datas['LONG_VSCOMREF_NAME'],
'vs_ref_replace' => $datas['VS_REF_REPLACE'],
'create_date' => $datas['CREATE_DATE'] ,
'last_update_date' => $datas['LAST_UPDATE_DATE'] ,
'lob_code' => $datas['LOB_CODE'],
'lob_name' => $datas['MADE_IN_CODE'],
'made_in_code' => $datas['MADE_IN_CODE'],
'made_in_en' => $datas['MADE_IN_EN'],
'made_in_fr' => $datas['MADE_IN_FR'],
'surcharge_code' =>$datas['SURCHARGE_CODE'],
'usageref' =>$datas['USAGEREF'],
'dp_family_code' =>$datas['DP_FAMILY_CODE'],
'dp_family_name' =>$datas['DP_FAMILY_NAME'],
'vehicle_cat_code_main' =>$datas['VEHICLE_CAT_CODE_MAIN'],
'brand_name' =>$datas['BRAND_NAME'],
'range_name' =>$datas['RANGE_NAME'],
'int_sap_status' =>$datas['INT_SAP_STATUS'],
'int_sap_status_old' =>$datas['INT_SAP_STATUS_OLD'],
'custom_code' =>$datas['CUSTOM_CODE'],
'sap_eng_designation' =>$datas['SAP_ENG_DESIGNATION'],
'segment_code' =>$datas['SEGMENT_CODE'],
'sene_type_code' =>$datas['SENE_TYPE_CODE'],
'projectrigin_ref' =>$datas['PROJECTRIGIN_REF'],
'ean_code' =>$datas['EAN_CODE'],
'ktypnr' =>$datas['KTYPNR'],
'specific_sales_org_code' =>$datas['SPECIFIC_SALES_ORG_CODE'],
'product_code' =>$datas['PRODUCT_CODE'],
'product_display' =>$datas['PRODUCT_DISPLAY'],
'product_family_display' =>$datas['PRODUCT_FAMILY_DISPLAY'],
'name_cl_manufacturer' =>$datas['NAME_CL_MANUFACTURER'],
'csu_gross_weight' =>$datas['CSU_GROSS_WEIGHT'],
'csu_nber_item' =>$datas['CSU_NBER_ITEM'],
'gamma' =>$datas['GAMMA'],
'sub_range' =>$datas['SUB_RANGE'],
'vehicle_ids' =>$datas['VEHICLE_IDS'],
'vehicle_cat_code_lcv' =>$datas['VEHICLE_CAT_CODE_LCV'],
'vehicle_cat_code_trucks' =>$datas['VEHICLE_CAT_CODE_TRUCKS'],
'vehicle_cat_code_agri' =>$datas['VEHICLE_CAT_CODE_AGRI'],
'vehicle_cat_code_const' =>$datas['VEHICLE_CAT_CODE_CONST'],
'vehicle_cat_code_trailer' =>$datas['VEHICLE_CAT_CODE_TRAILER'],
'vehicle_cat_code_gar' =>$datas['VEHICLE_CAT_CODE_GAR'],
'vehicle_cat_code_marine' =>$datas['VEHICLE_CAT_CODE_MARINE'],
'vehicle_cat_code_bus' =>$datas['VEHICLE_CAT_CODE_BUS'],
))
->execute();
$tab_req[] = '( "'.$datas['SHORT_VSCOMREF_NAME'].'", "'.$datas['LONG_VSCOMREF_NAME'].'", "'.$datas['VS_REF_REPLACE'].'", "'.$datas['CREATE_DATE'].'", '
. '"'.$datas['LAST_UPDATE_DATE'].'", "'.$datas['LOB_CODE'].'", "'.$datas['LOB_NAME'].'", "'.$datas['MADE_IN_CODE'].'", "'.$datas['MADE_IN_EN'].'", '
. '"'.$datas['MADE_IN_FR'].'", "'.$datas['SURCHARGE_CODE'].'", "'.$datas['USAGEREF'].'", "'.$datas['DP_FAMILY_CODE'].'", "'.$datas['DP_FAMILY_NAME'].'", '
. '"'.$datas['VEHICLE_CAT_CODE_MAIN'].'", '
. '"'.$datas['BRAND_NAME'].'", "'.$datas['RANGE_NAME'].'", "'.$datas['INT_SAP_STATUS'].'", "'.$datas['INT_SAP_STATUS_OLD'].'", "'.$datas['CUSTOM_CODE'].'", '
. '"'.$datas['SAP_ENG_DESIGNATION'].'", "'.$datas['SEGMENT_CODE'].'", "'.$datas['SENE_TYPE_CODE'].'", "'.$datas['PROJECTRIGIN_REF'].'", "'.$datas['EAN_CODE'].'", '
. '"'.$datas['KTYPNR'].'", "'.$datas['SPECIFIC_SALES_ORG_CODE'].'", "'.$datas['PRODUCT_CODE'].'", "'.$datas['PRODUCT_DISPLAY'].'", "'.$datas['PRODUCT_FAMILY_DISPLAY'].'", '
. '"'.$datas['NAME_CL_MANUFACTURER'].'", "'.$datas['CSU_GROSS_WEIGHT'].'", "'.$datas['CSU_NBER_ITEM'].'", "'.$datas['GAMMA'].'", "'.$datas['SUB_RANGE'].'", '
. '"'.$datas['VEHICLE_IDS'].'", "'.$datas['VEHICLE_CAT_CODE_LCV'].'", "'.$datas['VEHICLE_CAT_CODE_TRUCKS'].'", "'.$datas['VEHICLE_CAT_CODE_AGRI'].'", '
. '"'.$datas['VEHICLE_CAT_CODE_CONST'].'", "'.$datas['VEHICLE_CAT_CODE_TRAILER'].'", "'.$datas['VEHICLE_CAT_CODE_GAR'].'", "'.$datas['VEHICLE_CAT_CODE_MARINE'].'", '
. '"'.$datas['VEHICLE_CAT_CODE_BUS'].'" )';
} catch (PDOException $e) {
$LOGS .= '- Erreur ligne '.$num_ligne.' > '.$e->getMessage().' champs incorrects'."\n";
$flag_error=true;
continue;
}
$LOGS .= $num_ligne_ok.'/'.($num_ligne-1).' lignes exalead vscomref importées'."\n";
$num_ligne_ok++;
}
}
}
if($mode=='import'&&!empty( $tab_req)) {
$tab_req = array();
try{
$alter_column = ' ALTER TABLE `project_webcat_product_tmp_'.$div_lower.'`
ADD COLUMN `visuel_ref` VARCHAR(255) NOT NULL AFTER `long_vscomref_name`,
ADD COLUMN `id_family` SMALLINT(6) NOT NULL AFTER `last_update_date`,
ADD COLUMN `id_family_parent` SMALLINT(6) NOT NULL AFTER `id_family`,
ADD COLUMN `id_family_product` SMALLINT(6) NOT NULL AFTER `id_family_parent`,
ADD COLUMN `flag_enabled_'.$div_lower.'` TINYINT(4) NOT NULL AFTER `id_family_product` ';
db_query($alter_column);
} catch (PDOException $e) {
$LOGS .= '- Erreur ADD COLUMN > '.$e->getMessage().' incorrects';
$flag_error=true;
continue;
}
try{
db_add_index('project_webcat_product_tmp_'.$div_lower, 'visuel_ref', array('visuel_ref'));
db_add_index('project_webcat_product_tmp_'.$div_lower, 'id_family', array('id_family'));
db_add_index('project_webcat_product_tmp_'.$div_lower, 'id_family_parent', array('id_family_parent'));
db_add_index('project_webcat_product_tmp_'.$div_lower, 'id_family_product', array('id_family_product'));
db_add_index('project_webcat_product_tmp_'.$div_lower, 'flag_enabled_'.$div_lower, array('flag_enabled_'.$div_lower));
db_add_index('project_webcat_product_tmp_'.$div_lower, 'product_code', array('product_code'));
} catch (PDOException $ex) {
$LOGS .= $e->getMessage()."\n";
$flag_error=true;
continue;
}
/*
try{
$up_id_family = ' UPDATE `project_webcat_product_tmp_'.$div_lower.'` pt, `project_webcat_product_'.$div_lower.'` p SET pt.id_family=p.id_family WHERE pt.product_code=p.product_code ';
db_query($up_id_family);
} catch (PDOException $e) {
$LOGS .= $e->getMessage()."\n";
$flag_error=true;
continue;
}
*/
try{
$up_id_family = ' UPDATE `project_webcat_product_tmp_'.$div_lower.'` pt, `project_webcat_family` f SET pt.id_family=f.id_parent WHERE f.family_level = 3 AND pt.product_code=f.project_code ';
db_query($up_id_family);
} catch (PDOException $e) {
$LOGS .= $e->getMessage()."\n";
$flag_error=true;
continue;
}
try{
$up_id_family_parent = ' UPDATE `project_webcat_product_tmp_'.$div_lower.'` pt, `project_webcat_family` f SET pt.id_family_parent=f.id_family WHERE f.family_level = 1 AND pt.lob_code=f.project_code ';
db_query($up_id_family_parent);
} catch (PDOException $e) {
$LOGS .= $e->getMessage()."\n";
$flag_error=true;
continue;
}
try{
$up_id_family_product = ' UPDATE `project_webcat_product_tmp_'.$div_lower.'` pt, `project_webcat_family` f SET pt.id_family_product=f.id_family WHERE f.family_level = 3 AND pt.product_code=f.project_code ';
db_query($up_id_family_product);
} catch (PDOException $e) {
$LOGS .= $e->getMessage()."\n";
$flag_error=true;
continue;
}
try{
$update_visuel_ref = ' UPDATE `project_webcat_product_tmp_'.$div_lower.'` pt, `project_webcat_product_'.$div_lower.'` p SET pt.visuel_ref=p.visuel_ref WHERE pt.long_vscomref_name=p.long_vscomref_name ';
db_query($update_visuel_ref);
} catch (PDOException $e) {
$LOGS .= $e->getMessage()."\n";
$flag_error=true;
continue;
}
/*
try{
$update_flag_enabled = ' UPDATE `project_webcat_product_tmp_'.$div_lower.'` pt, `project_webcat_product_'.$div_lower.'` p SET pt.flag_enabled_'.$div_lower.'=p.flag_enabled_'.$div_lower.' WHERE pt.long_vscomref_name=p.long_vscomref_name ';
db_query($update_flag_enabled);
} catch (PDOException $e) {
$LOGS .= $e->getMessage()."\n";
$flag_error=true;
continue;
}
*/
/** RENAME TABLE **/
$count_tmp = db_query(" SELECT COUNT(*) AS nb FROM project_webcat_product_tmp_$div_lower ")->fetchField();
//$nb_ligne_ok = ($num_ligne_ok-$num_ligne);
if ($count_tmp > 500){
try{
db_rename_table('project_webcat_product_'.$div_lower, 'project_webcat_product_'.$div_lower.'_OLD_'.$today);
$LOGS .= '- RENAME Table OLD REUSSI > project_webcat_product_'.$div_lower.'_OLD_'.$today."\n" ;
} catch (PDOException $e) {
$LOGS .= $e->getMessage();
$flag_error=true;
continue;
}
try{
db_rename_table('project_webcat_product_tmp_'.$div_lower, 'project_webcat_product_'.$div_lower);
$LOGS .= '- RENAME Table TMP REUSSI > project_webcat_product_'.$div_lower."\n" ;
} catch (PDOException $e) {
$LOGS .= $e->getMessage();
$flag_error=true;
continue;
}
}
/** RENAME TABLE **/
}
$LOGS .= $num_ligne_ok.'/'.($num_ligne-1).' lignes exalead vscomref importées'."\n";
} else {
$flag_error=true;
$LOGS .= 'Erreur FATALE : Fichier introuvable'."\n";
}
$LOGS .= 'Fin '.$file.' : '.date('Y-m-d H:i:s', time())."\n";
$LOGS .= '----------------------------------------------------------------'."\n";
$LOGS .= "\n".'Fin script : '.date('Y-m-d H:i:s', time())."\n";
$F_LOGS=fopen($document_root."/sites/all/modules/project/webcatalog/import/logs/vscomref_log/".$log_file, 'w');
fwrite($F_LOGS, $LOGS);
fclose($F_LOGS);
chmod($document_root."/sites/all/modules/project/webcatalog/import/logs/vscomref_log/".$log_file, 0775);
}
// Call Drupal Mail
//webcatalog_vscomref_mail('default_from', 'some email GDPR', 'UPDATE EXALEAD PROJECT', $LOGS);
}
/**
* Simple wrapper function for drupal_mail() to avoid extraneous code.
*/
//function webcatalog_vscomref_mail($from = 'default_from', $to, $subject, $message) {
function webcatalog_vscomref_mail($body) {
/* $my_module = 'webcatalog_vscomref';
$my_mail_token = microtime();
if ($from == 'default_from') {
// Change this to your own default 'from' email address.
$from = variable_get('system_mail', 'some email GDPR');
}
$message = array(
'id' => $my_module . '_' . $my_mail_token,
'to' => $to,
'subject' => $subject,
'body' => array($message),
'headers' => array(
'From' => $from,
'Sender' => $from,
'Return-Path' => $from,
),
);
$system = drupal_mail_system($my_module, $my_mail_token);
$message = $system->format($message);
if ($system->mail($message)) {
return TRUE;
}
else {
return FALSE;
}*/
/*
$to = variable_get('webcatalog_vscomref_destinataires', 'some email GDPR');
$subject = variable_get('webcatalog_vscomref_subject', 'UPDATE EXALEAD PROJECT');
$body = variable_get('webcatalog_vscomref_body', $body);
*/
/*$to = 'some email GDPR';
$subject = 'UPDATE EXALEAD PROJECT';
$message = array(
'from' => 'some email GDPR',
'to' => $to,
'id' => 'webcatalog_vscomref_mail',
'subject' => $subject,
'body' => $body,
);*/
//$message = 'New signup email address'; // Body of your email here.
$params = array(
'body' => $body,
'subject' => 'UPDATE EXALEAD PROJECT',
'headers'=>'simple',
);
$to = "some email GDPR";
drupal_mail('webcatalog_vscomref', 'send_logs', $to, language_default(), $params, 'Mehdi.Sektaoui@agence-one.com', TRUE);
}
/**
* for function _get_division()
* function to retrieve the list of code division
*
* @return array
*/
function _list_division() {
static $liste_division = array();
if(empty($liste_division)) {
$q = db_query("SELECT DISTINCT code_division FROM {project_webcat_division} WHERE code_division <>'' ORDER BY code_division " );
foreach ($q as $object) {
$types[$object->code_division] = $object->code_division;
}
}
else {
return $types;
}
return $types;
}
/**
* Return docroot dir.
*/
function _get_document_root() {
if ( ($GLOBALS['conf']['environnement'] == 'MAQUETTE') ){
return $_SERVER['DOCUMENT_ROOT'];
}else{
return "/space/www/projectservice/data/current";
}
}
/**
* Conversion des données (Encodage UTF-8)
*
* @param $csv_datas
* @return mixed
* Return csv datas
*/
function _conversion_csv_data($csv_datas) {
foreach($csv_datas as $key=>$val) {
$csv_datas[$key] = utf8_encode(trim($val));
}
return $csv_datas;
}