Created
May 28, 2013 11:19
-
-
Save koo5/5662063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="http://www.freediff.com/"></a><br> | |
<a href="pohoda.txt"></a><br> | |
<a href="fio.txt"></a><br> | |
<?php | |
#vypis z pohody,text,ansi nebo oem dalo to samy | |
#zaklikavaj se sloupecky, zakliknout vsechny, viz niz | |
// diff -y fio.txt pohoda.txt > xxx.txt | |
date_default_timezone_set('Europe/Prague'); | |
$fio = array(); | |
#vypis z ebanky | |
$a = fopen($argv[1], "r"); | |
for($i=0;$i<10;$i++) | |
fgets($a); | |
while($b=fgets($a)) | |
$fio[] = explode(";", $b); | |
$fio=array_splice($fio,0,sizeof($fio)-2); | |
for($i=0;$i<sizeof($fio);$i++) | |
$fio[$i] = array(date_create( $fio[$i][1])->getTimestamp(), preg_replace("/ /", "", $fio[$i][2])); | |
$pohoda = array(); | |
#vypis z pohody,text,ansi nebo oem dalo to samy | |
#zaklikavaj se sloupecky, zakliknout vsechny | |
$a = fopen($argv[2], "r"); | |
#nabereme radky(?) | |
while($b=fgets($a)) | |
$pohoda[] = explode(";", $b); | |
#odebereme hlavicku souboru | |
$pohoda=array_splice($pohoda, 1); | |
#pro kazdou radku | |
for($i=0;$i<sizeof($pohoda);$i++) | |
{ | |
$p = $pohoda[$i]; | |
print_r($p); | |
// $lolatphp=explode(" ",$p[32]); | |
#vsechny sloupce, 4 je datum, 8 je "Prijem/Vydej", 6 je castka | |
#vypis bez prijem/vydej mel divny znaminka | |
$pohoda[$i]= array(date_create($p[4])->getTimestamp(), ($p[8][1]==='V'? "-":""). substr($p[6],0,-3)); | |
// print_r($pohoda[$i]); | |
} | |
function cmp($a,$b) | |
{ | |
if ($a[0] == $b[0]) | |
{ | |
if($a[1]==$b[1]) | |
return 0; | |
else if ($a[1]<$b[1]) | |
return -1; | |
else return 1; | |
} | |
else if ($a[0]<$b[0]) | |
return -1; | |
else return 1; | |
} | |
//print_r($pohoda); | |
usort($pohoda, "cmp"); | |
usort($fio, "cmp"); | |
$po = fopen("pohoda.txt", "w"); | |
foreach ($pohoda as $b) | |
{ | |
$d = getdate($b[0]); | |
// print_r($d); | |
fwrite($po, $d['year']." ".$d['mon']." ".$d['mday']." ".$b[1]."\n"); | |
} | |
$fi = fopen("fio.txt", "w"); | |
foreach ($fio as $b) | |
{ | |
// print_r($b); | |
$d =getdate($b[0]); | |
fwrite($fi, $d['year']." ".$d['mon']." ".$d['mday']." ".$b[1]."\n"); | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment