0
Hi, I need a tip, I was making an import of a file on CSV to change a record in my database and strangely could not do it, I did an analysis in the code in PHP and it’s all right so I left for the file on CSV and found that the same after the tests I did was left blank lines at the end of it, I did a cleaning and again I remade the import process and everything worked out.
Is there any possibility to delete these lines after the records at the time of import?
What I got is this:
if (!empty($_FILES)) {
$tempFile = $_FILES['userImage']['tmp_name'];
$Dados = file($tempFile);
// IGNORANDO A PRIMEIRA LINHA DO CSV
array_shift($Dados);
foreach($Dados as $RegLinhas) {
// RETIRA ESPAÇOS NO INÍCIO E FIM
$Linha = trim($RegLinhas);
// DIVIDE A STRING
$CamposImport = explode(';', $Linha);
// RECUPERANDO EM VARIÁVES PARA ORGANIZAR SELECT/INSERT/UPDATE
$IdPessoa = $CamposImport[0];
$Nome = $CamposImport[1];
$IdUnicoop = $CamposImport[2];
$DataAdmissao = $CamposImport[3];
$IdCargo = $CamposImport[4];
$LotacaoRH = $CamposImport[5];
$CTPS = $CamposImport[6];
$CTPSSerie = $CamposImport[7];
$CTPSUF = $CamposImport[8];
$DataNascimento = $CamposImport[9];
$CPF = $CamposImport[11];
// CONVERTENDO DATA PARA MYSQL
$DataAdmissao = implode("-",array_reverse(explode("/",$DataAdmissao)));
$DataNascimento = implode("-",array_reverse(explode("/",$DataNascimento)));
// CAMPOS FIXOS
$TipoColaborador = "Funcionario";
$DivulgarAniversario = 1;
$Categoria = "F";
$ClienteProdutor = "C";
$Fornecedor = 0;
$Colaborador = 1;
$Ativo = 1;
}
}
You can do an If in fields that will never appear empty. For example: If Idperson other than empty, receives other information...
– Bruno Folle
Thanks for the tip @Brunofolle, I’ll do some tests.
– adventistapr