1. Go to this page and download the library: Download fgsl/csvextractor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fgsl / csvextractor example snippets
use Fgsl\CsvExtractorInterface;
class DecoratorMunicipios implements CsvExtractorInterface {
/**
* Value treatment and definition of INSERT statement
*/
public function getValues(array $row): string
{
$values = "'" . $row[11] . "'," . // CODIGO_MUNICIPIO
"'" . str_replace("'","\'",$row[12]) . "'" . ',' . // NOME_MUNICIPIO
"'" . $row[0] . "'" . ',' . // CODIGO_UF
"'" . $row[1] . "'" . ',' . // NOME_UF
$row[4]; // CODIGO_IBGE
return $values;
}
/**
* General implementation:
* $values = getValues($row);
* return "INSERT INTO (...) VALUES ($values)";
*/
public function getSqlStatement(array $row): string
{
$values = $this->getValues($row);
$sql = "INSERT INTO municipios(CODIGO_MUNICIPIO, NOME_MUNICIPIO, CODIGO_UF, NOME_UF, CODIGO_IBGE) VALUES ($values)";
return $sql;
}
}
?php
ude 'DecoratorMunicipios.php';
use Fgsl\CsvExtractor;
$csvExtractor = new CsvExtractor(
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.