CSV
to change a record in my database and strangely I could not do it, I did an analysis in the code in PHP
and it's alright so I left for the file in CSV
and I discovered that the same after the tests I did was left with blank lines at the end of it, I did a cleanup and I re-started the import process and everything went well.
Is there any possibility of deleting these rows after the records at the time of import?
What I have 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; } }