From 914dc87c49752c602d05e171efe6fd438164ee94 Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Fri, 08 Feb 2019 09:42:54 +0000 Subject: [PATCH] Save parsing results to file using PHP --- parse.php | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/parse.php b/parse.php index c1232f8..02e5f28 100644 --- a/parse.php +++ b/parse.php @@ -10,6 +10,7 @@ 'gtfs_file' => 'VehiclePositions_A.pb', 'ttss' => 'http://91.223.13.70/internetservice/geoserviceDispatcher/services/vehicleinfo/vehicles', 'ttss_file' => 'vehicles_A.json', + 'result' => 'mapping_A.json', ], ]; @@ -36,7 +37,11 @@ if($offset) { $logger->info('Got offset '.$offset.', creating mapping...'); $mapping = $mapper->getMapping($offset); - echo json_encode($mapping); + $json = json_encode($mapping); + if(!file_put_contents(__DIR__.'/data/'.$source['result'].'.tmp', $json)) { + throw new Exception('Result save failed'); + } + rename(__DIR__.'/data/'.$source['result'].'.tmp', __DIR__.'/data/'.$source['result']); } $logger->info('Finished'); } catch(Throwable $e) { -- Gitblit v1.9.1