No description
Find a file
Vítězslav Dvořák 862da6e84f ZIP Code support added
2020-09-24 23:35:52 +02:00
importer ZIP Code support added 2020-09-24 23:35:52 +02:00
.gitignore .gitignore updates 2015-10-22 12:00:42 +03:00
composer.json change fgetcsv to str_getcsv 2016-06-16 17:12:22 +03:00
LICENSE Initial commit 2015-10-22 11:33:07 +03:00
README.md Update README.md 2016-03-13 08:51:26 +03:00

Geonames.org importer API

CSV data importer from geonames.org

Use open CSV base from geonames:

  • cities bases (cities5000.zip, cities15000.zip, RU.zip, US.zip, etc.)
  • countries base
  • states base (admin1code.csv)

Installation

Run in your console

php composer.phar require "kalyabin/geonames-importer" "dev-master"

Import all countries

$importer = new \kalyabin\geonames\importer\Country('/tmp/', function($country) {
    print 'Consume country: ' . "\n";
    print_r($country);
    print "\n";
    // do something else
});
$importer->process();

Import cities

$importer = new \kalyabin\geonames\importer\City('/tmp/', 'cities5000.zip', function($city) {
    print 'Consume city: ' . "\n";
    print_r($city);
    print "\n";
    // do something else
});
$importer->process();

You may type second param like RU.zip, US.zip, cities15000.zip, etc.

Import states

$importer = new \kalyabin\geonames\importer\Admin1CodeASCII('/tmp/', function($region) {
    fwrite(STDOUT, "Consume region: ");
    print_r($region);
    fwrite(STDOUT, "\n");
});
$importer->process();

More about geonames open base read at http://download.geonames.org/export/dump/readme.txt