WIP RTR Reporting
This commit is contained in:
4
scripts/import/.gitignore
vendored
Normal file
4
scripts/import/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
*
|
||||
!.gitignore
|
||||
!100mraster
|
||||
!100mraster/*
|
||||
80
scripts/import/100mraster/import-100m-raster.php
Normal file
80
scripts/import/100mraster/import-100m-raster.php
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
define("INTERNAL_USER_ID", $me->id);
|
||||
define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
$bundeslaender = [
|
||||
"Burgenland",
|
||||
"Kaernten",
|
||||
"Niederoesterreich",
|
||||
"Oberoesterreich",
|
||||
"Salzburg",
|
||||
"Steiermark",
|
||||
"Tirol",
|
||||
"Vorarlberg",
|
||||
"Wien"
|
||||
];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
foreach($bundeslaender as $bland) {
|
||||
$filename = __DIR__ . "/csv/StatistikAustria_100mRaster_Anschlusspotential2022_$bland.csv";
|
||||
|
||||
if(!file_exists($filename)) {
|
||||
die("File $filename not found!\n");
|
||||
}
|
||||
|
||||
|
||||
$input = fopen($filename, "r");
|
||||
|
||||
$bom = "\xef\xbb\xbf";
|
||||
if(fgets($input, 4) !== $bom) {
|
||||
// BOM not found - rewind pointer to start of file.
|
||||
rewind($input);
|
||||
|
||||
}
|
||||
|
||||
$headers = [];
|
||||
|
||||
$i = 0;
|
||||
while($csv = fgetcsv($input, 0, ";")) {
|
||||
$i++;
|
||||
|
||||
if($i == 1) {
|
||||
foreach($csv as $key => $name) {
|
||||
$headers[$name] = $key;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!trim($csv[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$raster = trim($csv[$headers["rasterid"]]);
|
||||
$unit_count = trim($csv[$headers["anschlusspotential"]]);
|
||||
|
||||
$sql = "INSERT INTO `Rtr100mRaster` (`raster`,`unit_count`,`create_by`,`edit_by`,`create`,`edit`) VALUES('$raster',$unit_count,1,1,1733431100,1733431100)";
|
||||
$db->query($sql);
|
||||
|
||||
/*
|
||||
$rtr100mraster = Rtr100mRaster::create([
|
||||
"raster" => $raster,
|
||||
"unit_count" => $unit_count,
|
||||
]);
|
||||
$rtr100mraster->save()*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user