diff --git a/crawler/crawler.php b/crawler/crawler.php index 2195656..eb426ad 100644 --- a/crawler/crawler.php +++ b/crawler/crawler.php @@ -6,7 +6,9 @@ $GLOBALS['db'] = new SQLite3('data.db'); if(!$GLOBALS['db']) exit("Error loading database"); -var_dump($GLOBALS['db']); +//389-7625.pdf.csv +// analyzeResultCSV('tmp/csv/389-7625.pdf.csv',7625,389); +// exit(); $html = file_get_contents('tmp/ergebnisse.html'); @@ -165,9 +167,9 @@ function getResults($run,$event) analyzeResultCSV('tmp/csv/' . $event . '-' . $run . '.pdf.csv',$run,$event); } -function analyzeResultCSV($csv,$run,$event) +function analyzeResultCSV($csvfile,$run,$event) { - $csv = array_map('str_getcsv', file($csv)); + $csv = array_map('str_getcsv', file($csvfile)); //prepare header for database foreach($csv[0] as $key=>$value){ @@ -192,6 +194,7 @@ function analyzeResultCSV($csv,$run,$event) $zeit = $row['zeit']; $gf = $row['gf']; $msek = $row['msek']; + $punkte = $row['punkte']; $bew = $row['bew']; //add result to db if not exists @@ -199,7 +202,8 @@ function analyzeResultCSV($csv,$run,$event) { $res = $GLOBALS['db']->query("SELECT * FROM results WHERE stnr = '$stnr' AND run = '$run' AND event = '$event'"); if($res->fetchArray() == false) - $GLOBALS['db']->exec("INSERT INTO results (stnr, rang, run, event, teilnehmer, hund, verein, f, vw, zf, zeit, gf, msek, bew) VALUES ('$stnr', '$rang', '$run', '$event', '$teilnehmer', '$hund', '$verein', '$f', '$vw', '$zf', '$zeit', '$gf', '$msek', '$bew')"); + $GLOBALS['db']->exec("INSERT INTO results (stnr, rang, run, event, teilnehmer, hund, verein, f, vw, zf, zeit, gf, msek, bew, punkte) VALUES ('$stnr', '$rang', '$run', '$event', '$teilnehmer', '$hund', '$verein', '$f', '$vw', '$zf', '$zeit', '$gf', '$msek', '$bew', '$punkte')"); + //else echo " [i] Skipping $teilnehmer in run $run in event $event\n"; } catch(Exception $ex) { //die( $ex->getMessage() ); diff --git a/crawler/data.db b/crawler/data.db index f2c07a1..420075f 100644 Binary files a/crawler/data.db and b/crawler/data.db differ