]> git.nbdom.net Git - nb.git/commitdiff
share/sql/zipcode.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 4 Jan 2018 00:07:29 +0000 (00:07 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 4 Jan 2018 00:07:29 +0000 (00:07 +0000)
share/db/timezone
share/db/zipcode [deleted file]
share/sql/zipcode [new file with mode: 0755]

index 7c1f5155796dfe42572ee91dfc18b08c1038bc13..07238622b40b690e605c476b0a43ae245e01b7ff 100755 (executable)
@@ -8,7 +8,6 @@ while (<>) {
        next unless $i++;
        chomp($_);
        @_ = (split("\t",$_))[1,2,3,4];
-       #push @_,0 if (@_<4);
        #$_[1] = join("\t",reverse split('/',$_[1]));
        print join ("\t",@_)."\n";
 }
diff --git a/share/db/zipcode b/share/db/zipcode
deleted file mode 100755 (executable)
index c9ce255..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-#exec('curl -s http://download.geonames.org/export/zip/allCountries.zip | zcat');
-#exit;
-@ARGV = ('curl -s http://download.geonames.org/export/zip/allCountries.zip | zcat |');
-
-while (<>) {
-       chomp($_);
-       @_ = split("\t",$_);
-       print join ("\t",@_)."\n";
-}
diff --git a/share/sql/zipcode b/share/sql/zipcode
new file mode 100755 (executable)
index 0000000..c91bcc4
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+#exec('curl -s http://download.geonames.org/export/zip/allCountries.zip | zcat');
+#exit;
+@ARGV = ('curl -s http://download.geonames.org/export/zip/allCountries.zip | zcat |');
+
+while (<>) {
+       chomp($_);
+       s,\\\t,\t,g; # fix error
+       @_ = split("\t",$_);
+       push @_,0 if (@_<12);
+
+       $_ = $_[0];
+       $_[0] = $_[1];
+       $_[1] = $_;
+        
+
+       print join ("\t",@_)."\n";
+}