<commit_before><?php
if(php_sapi_name()=="cli")
{
    $regione=$argv[1];
}

$json=json_decode(file_get_contents($regione),true);
$arr=$json['array'];

echo "Processing ".$regione."\n";

try{
    $file_db = new PDO('sqlite:db/scrape.sqlite');
    $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    $dis_sql='INSERT OR REPLACE INTO `distributori`(`id`, `name`, `bnd`, `lat`, `lon`, `addr`, `comune`, `provincia`) ';
    $dis_sql.='VALUES (:id,:name,:bnd,:lat,:lon,:addr,:comune,:provincia)';
    $dis_sth   = $file_db->prepare($dis_sql);

    $carb_sql='INSERT OR REPLACE INTO `prezzi`(`id_d`, `dIns`, `carb`, `isSelf`, `prezzo`) ';
    $carb_sql.='VALUES (:id_d,:dIns,:carb,:isSelf,:prezzo)';
    $carb_sth   = $file_db->prepare($carb_sql);

    $file_db->beginTransaction();
    foreach($arr as $entry){
	$addr=$entry['addr'];
	preg_match('/.*#(.*)\((.*)\)/',$addr, $matches);
	$dis_sth->execute(array(':id' => $entry['id'], ':name' => $entry['name'],':bnd' => $entry['bnd'],':lat' => $entry['lat'],':lon' => $entry['lon'],':addr' => $entry['addr'],':comune' => ucwords(strtolower(trim($matches[1]))),':provincia' => $matches[2]) );

        $carburanti=$entry['carburanti'];
        foreach ($carburanti as $carb){
            $carb_sth->execute(array(':id_d' => $entry['id'], ':dIns' => $entry['dIns'],':carb' => $carb['carb'],':isSelf' => $carb['isSelf'],':prezzo' => $carb['prezzo']) );
        }
    }
    $file_db->commit();
<commit_msg>Add fix<commit_after><?php
if(php_sapi_name()=="cli")
{
    $regione=$argv[1];
}

$json=json_decode(file_get_contents($regione),true);
$arr=$json['array'];

echo "Processing ".$regione."\n";

try{
    $file_db = new PDO('sqlite:db/scrape.sqlite');
    $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    $dis_sql='INSERT OR REPLACE INTO `distributori`(`id`, `name`, `bnd`, `lat`, `lon`, `addr`, `comune`, `provincia`) ';
    $dis_sql.='VALUES (:id,:name,:bnd,:lat,:lon,:addr,:comune,:provincia)';
    $dis_sth   = $file_db->prepare($dis_sql);

    $carb_sql='INSERT OR REPLACE INTO `prezzi`(`id_d`, `dIns`, `carb`, `isSelf`, `prezzo`) ';
    $carb_sql.='VALUES (:id_d,:dIns,:carb,:isSelf,:prezzo)';
    $carb_sth   = $file_db->prepare($carb_sql);

    $file_db->beginTransaction();
    foreach($arr as $entry){
	$addr=$entry['addr'];
	$r=preg_match('/.*#(.*)\((.*)\)/',$addr, $matches);
	if($r==0||$r===NULL) $matches=['','',''];
	$dis_sth->execute(array(':id' => $entry['id'], ':name' => $entry['name'],':bnd' => $entry['bnd'],':lat' => $entry['lat'],':lon' => $entry['lon'],':addr' => $entry['addr'],':comune' => ucwords(strtolower(trim($matches[1]))),':provincia' => $matches[2]) );

        $carburanti=$entry['carburanti'];
        foreach ($carburanti as $carb){
            $carb_sth->execute(array(':id_d' => $entry['id'], ':dIns' => $entry['dIns'],':carb' => $carb['carb'],':isSelf' => $carb['isSelf'],':prezzo' => $carb['prezzo']) );
        }
    }
    $file_db->commit();

{'fraction_non_alphanumeric': 0.2830188679245283, 'fraction_numerical': 0.0023584905660377358, 'mean_word_length': 5.671910112359551, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3697473', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1195, 'n_words': 149}