About: Lookup the city and state of a given US Zip code using TCL   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

This works by accessing the USPS web site, so one needs to be online for this to work. Since the code parses the HTML code, this breaks whenever the web site code is reorganized, which seems to happen every other year or so, but can be fixed by adjusting the regexp (which may take a bit of fiddling). The code is in TCL, so one needs to use a TCL-enabled version of Vim. The following should go in your gvimrc file: and this into utilities.tcl:

AttributesValues
rdfs:label
  • Lookup the city and state of a given US Zip code using TCL
rdfs:comment
  • This works by accessing the USPS web site, so one needs to be online for this to work. Since the code parses the HTML code, this breaks whenever the web site code is reorganized, which seems to happen every other year or so, but can be fixed by adjusting the regexp (which may take a bit of fiddling). The code is in TCL, so one needs to use a TCL-enabled version of Vim. The following should go in your gvimrc file: and this into utilities.tcl:
Version
  • 5(xsd:double)
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 895(xsd:integer)
Author
  • Ulf Dittmer
Complexity
  • basic
Created
  • 2005-03-15(xsd:date)
ID
  • 896(xsd:integer)
NEXT
  • 897(xsd:integer)
Rating
  • 5(xsd:integer)
abstract
  • This works by accessing the USPS web site, so one needs to be online for this to work. Since the code parses the HTML code, this breaks whenever the web site code is reorganized, which seems to happen every other year or so, but can be fixed by adjusting the regexp (which may take a bit of fiddling). The code is in TCL, so one needs to use a TCL-enabled version of Vim. The following should go in your gvimrc file: if has("tcl") tclfile utilities.tcl " change the menu name and the menu item name as you see fit menu &Utilities.&ZipLookup :call ZIPLookup(expand("")) function ZIPLookup (word) tcl puts [ZipLookup [::vim::expr a:word]] endfunction endif and this into utilities.tcl: proc ZipLookup zipcode { package require http # some websites, not the usps necessarily, care what kind of browser is used. ::http::config -useragent "Mozilla/5.0 (X11; U; Linux 2.4.22; rv:1.7.5) Gecko/20041108 Firefox/1.0" set url "http://zip4.usps.com/zip4/zip_responseA.jsp"; while { [string length $zipcode] < 5 } { set zipcode "0$zipcode" } # the http man page is a good place to read up on these commands set query [::http::formatQuery zipcode $zipcode] set http [::http::geturl $url -query $query] set html [::http::data $http] # we use a regular expression pattern to extract the text we are looking for if {[regexp {row1 header1[^>]*>[^<]*]*>\s*([^<]+).*row1 header2.*([A-Z][A-Z]).*row1 header3} $html => city state]} { return "$zipcode ==> $city, $state" } else { return "$zipcode ==> not found" } }
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software