geo-ip: fixing csv.
parent
68fed78c7d
commit
d4b47612e1
|
@ -1,10 +1,9 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel sequences io.files io.files.temp io.launcher
|
USING: accessors arrays assocs combinators combinators.smart
|
||||||
io.pathnames io.encodings.ascii io.streams.string http.client
|
csv grouping http.client interval-maps io.encodings.ascii
|
||||||
generalizations combinators math.parser math.vectors
|
io.files io.files.temp io.launcher io.pathnames kernel math
|
||||||
math.intervals interval-maps memoize csv accessors assocs
|
math.parser math.vectors memoize sequences splitting strings ;
|
||||||
strings math splitting grouping arrays combinators.smart ;
|
|
||||||
IN: geo-ip
|
IN: geo-ip
|
||||||
|
|
||||||
: db-path ( -- path ) "IpToCountry.csv" cache-file ;
|
: db-path ( -- path ) "IpToCountry.csv" cache-file ;
|
||||||
|
@ -34,7 +33,7 @@ TUPLE: ip-entry from to registry assigned city cntry country ;
|
||||||
|
|
||||||
MEMO: ip-db ( -- seq )
|
MEMO: ip-db ( -- seq )
|
||||||
download-db ascii file-lines
|
download-db ascii file-lines
|
||||||
[ "#" head? not ] filter "\n" join <string-reader> csv
|
[ "#" head? not ] filter "\n" join string>csv
|
||||||
[ parse-ip-entry ] map ;
|
[ parse-ip-entry ] map ;
|
||||||
|
|
||||||
: filter-overlaps ( alist -- alist' )
|
: filter-overlaps ( alist -- alist' )
|
||||||
|
|
Loading…
Reference in New Issue