Nice :)

On Sat, Sep 7, 2019 at 2:00 AM Alex Harsanyi <alexharsa...@gmail.com> wrote:

> In fact, I updated the data frame package to be able to read the CSV file
> directly, without having to process it, so the example now becomes:
>
> #lang racket
> (require data-frame)
>
> (define df (df-read/csv "worldcities.csv" #:quoted-numbers? #t))
>
> (define ((is-city? name) v)
>   (equal? (vector-ref v 0) name))
>
> (df-select* df "city" "country" "lat" "lng" #:filter (is-city? "Perth"))
>
> ;; Produces:
>
> ;; '#(#("Perth" "Australia" -31.955 115.84)
> ;;      #("Perth" "United Kingdom" 56.4003 -3.47))
>
> Alex.
>
>
> On Saturday, September 7, 2019 at 8:13:28 AM UTC+8, Alex Harsanyi wrote:
>>
>>
>> That database is simple enough to use directly, not sure if it needs a
>> separate package:
>>
>> #lang racket
>> (require data-frame)
>>
>> ;; The worldcities.csv file has all values quoted, so df-read/csv reads
>> them
>> ;; all as strings.  Convert a series to numbers.
>> (define (->numeric df series)
>>   (df-add-derived df series (list series) (lambda (v) (string->number (car
>> v)))))
>>
>> (define df (df-read/csv "worldcities.csv"))
>>
>>   ;; Convert numeric series to numbers
>> (for ([series '("lat" "lng" "population")])
>>   (->numeric df series))
>>
>> (define ((is-city? name) v)
>>   (equal? (vector-ref v 0) name))
>>
>> (df-select* df "city" "country" "lat" "lng" #:filter (is-city? "Perth"))
>>
>> ;; The above call produces:
>>
>> ;; '#(#("Perth" "Australia" -31.955 115.84)
>> ;;    #("Perth" "United Kingdom" 56.4003 -3.47))
>>
>>
>>
>> Alex.
>>
>> On Friday, September 6, 2019 at 8:37:59 PM UTC+8, Laurent wrote:
>>>
>>> There's a small free database here too:
>>> https://simplemaps.com/data/world-cities
>>>
>>> I started writing a simple query system for it this morning (csv->rktd,
>>> then just list of assoc operations).
>>>
>>> On Fri, Sep 6, 2019 at 1:35 PM Sage Gerard <sa...@sagegerard.com> wrote:
>>>
>>>> Would geonames help?
>>>> http://www.geonames.org/
>>>>
>>>>
>>>> -------- Original Message --------
>>>> On Sep 6, 2019, 8:28 AM, Hendrik Boom < hen...@topoi.pooq.com> wrote:
>>>>
>>>>
>>>> On Thu, Sep 05, 2019 at 10:42:01PM -0700, Alex Harsanyi wrote:
>>>> ...
>>>> >
>>>> > >
>>>> > > A package containing a database of the positions of the major
>>>> cities and
>>>> > > countries would be nice too :)
>>>> > >
>>>> >
>>>> >
>>>> > A general facility able to resolve location names to GPS coordinates
>>>> would
>>>> > be a lot of work, and I don't have time for such a thing. Sorry.
>>>>
>>>> There must be a GPS database of cities available somewhere already.
>>>>
>>>> -- hendrik
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Racket Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to racket...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/racket-users/20190906122801.w5yhwfbzkods2fqr%40topoi.pooq.com.
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Racket Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to racket...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/racket-users/yGI9c5OlIwdUQNOQy4KIEMKSfaYia4pr4LkSRukDwvb1sTFJfIQ1As6ca3i8jKqz42EV74CWvr4wdmfhQIcDtbniv7KDj4PqI0Giw-t9q_c%3D%40sagegerard.com
>>>> <https://groups.google.com/d/msgid/racket-users/yGI9c5OlIwdUQNOQy4KIEMKSfaYia4pr4LkSRukDwvb1sTFJfIQ1As6ca3i8jKqz42EV74CWvr4wdmfhQIcDtbniv7KDj4PqI0Giw-t9q_c%3D%40sagegerard.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/d4353473-061d-4651-aedc-425351833968%40googlegroups.com
> <https://groups.google.com/d/msgid/racket-users/d4353473-061d-4651-aedc-425351833968%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CABNTSaHJ%3DRWdnNqxrPG%2B-1vmm74%3DoxQxHXjwH--j%3D%3D673TWcaA%40mail.gmail.com.

Reply via email to