Dobrý deň
Prosím Vás našiel by sa tu niekto kto by vedel prepísat tento kód ktorý je v PHP do Pyhonu ? Som v tomto novy a potrebujem to. Vopred ďakujem
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>phpChart - Basic Chart</title>
</head>
<body>
<?php
function array_delete($array, $element) {
return array_diff($array, $element);
}
$firs_constant = 0.005;
$secound_constant = 0.005;
$rozdielne[1000] = 0;
$link = mysqli_connect('127.0.0.1', 'webmaster', 'noerroronweb',"smart_meter");
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//echo 'Connected successfully<br>';
$result = mysqli_query($link,"SELECT date, current3 FROM `current` ORDER BY `current`.`date` ASC");
//$values = array(array('1',2.22),array('2',2.333),array('3',2.4),array('5',5.0));
$values = array();
$i=0;
echo "<br>";
$y=0;
while($row[$i++] = mysqli_fetch_array($result))
{
//echo "Pred: ".$row[$i-1]['current3']. "<br>";
if($row[$i-1]['current3'] == "0") $row[$i--];
//echo "Po: ". $row[$i-1]['current3']. "<br>";
//
}
for($z=0;$z<=$i; $z++){
//echo "Z: ".$z."<br>";
$rozdiel = $row[$z]['current3'] - $row[$z+1]['current3'] ;
if(abs($rozdiel)>=$firs_constant){
$rozdelove[$y] = abs($rozdiel);
$y++;
//echo "Rozdiel: ".$rozdiel."<br>";
}
}
echo "<h1>Vypis rozelnych hodnot</h1><br>";
$p=0;
for($z=0;$z<=$y; $z++){
$je=false;
for($m=$z-1;$m>=0; $m--){
$min = $rozdelove[$m]- $secound_constant;
$max = $rozdelove[$m]+ $secound_constant;
if($rozdelove[$z]<= $max && $rozdelove[$z]>= $min )
$je=true;
//echo $rozdelove[$z]." = ". $rozdelove[$m]."<br>";
}
if($je == false ){
$je=false;
//echo "Pocet: ".$p."<br>";
//echo "NOREPEAT: ".$rozdelove[$z]."<br>";
array_push($rozdielne,$z);
$p++;
}
}
for($m=0;$m<count($rozdelove);$m++){
for($k=0;$k<count($rozdelove);$k++){
if ($m!=$k){
$sucet = $rozdelove[$k] + $rozdelove[$m];
foreach ($rozdielne as &$value) {
if($sucet == $rozdelove[$value]){
//array_delete($rozdelove,$rozdelove[$value]);
echo "SUMMARY: ".$rozdelove[$value]."<br>";
echo "FOR VALUES: ".$rozdelove[$k]."a ". $rozdelove[$m] ."<br>";
}
}
}
}
}
echo "<pre>";
var_dump($rozdielne);
echo "</pre>";
?>
</body>
</html>