Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

From this list of weather data how can I discriminate only latitude longitude for each station?

For example from the following sample I would need only the coordinates:

  • "50136","","Aoluguya|Mohe, 15","","CN",52.13333,122.51667,433
  • "50246","","Tahe|Ta-He, 23","","CN",52.33330,124.80000,465
  • "50349","","Jinsong|Jiu-Hai-Lai, 15","","CN",51.13330,124.05000,610
share|improve this question
    
Like in SortBy[]? –  belisarius May 17 at 15:34
    
problem is how to discriminate stations lat lon ?? Some stations.... Example:Russian stations .. I think import[txt] . –  BatbuyanMGL May 17 at 15:39
    
Have you tried anything? Like playing with Part? Cases or something? –  Öskå May 17 at 15:53
    
importing some data txt file then cases –  BatbuyanMGL May 17 at 15:59

1 Answer 1

up vote 0 down vote accepted

Here is an approach based on the construction of your list:

rawdata = 
  Import["http://weather.gladstonefamily.net/cgi-bin/location.pl/pjsg_all_location.csv?csv=1"];

If you check how your list is constructed you have:

Tally[Map[Head, rawdata, {2}]]// Column
{{{{Integer, String, String, String, String, Real, Real, Integer}, 14471}},
 {{{String, String, String, String, String, Real, Real, Integer}, 33197}},
 {{{Integer, String, String, String, String, String, Real, Real, Integer}, 42}},
 {{{Real, String, String, String, String, Real, Real, Integer}, 2}},
 {{{String, Integer, String, String, String, Real, Real, Integer}, 4720}},
 {{{String, String, String, String, String, String, String, String, String, Real, Real, Integer}, 1}},
 {{{String, String, String, String, String, String, Real, Real, Integer}, 14}},
 {{{String, String, String, Real, Real, Integer}, 4}},
 {{{String, String, String, String, String, String, String, Real, Real, Integer}, 1}}}

You can see if you wish keep only the Reals you are interested in (a.k.a. the coordinates) you need to delete the first column in order to keep only the coordinates:

Cases[#, _Real] & /@ rawdata[[All, 2 ;;]]
{{65.98222, -161.15194}, {35.35052, -116.88837}, {37.24776, -112.82244}, <<52446>>, 
 {41.78283, 123.49491}, {46.3326, 16.6093}, {40.33093, -3.74632}}

Note that it's very specific to your case and the way your list is constructed but the same approach can be used with different lists.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.