4
Pick six cities or villages, one from each of the populated continents, Asia, Africa, North America, South America, Europe and Australia. The forecasts cover 8351174 places, more than 2 million in the US, 150000 in Pakistan, 10000 in Uganda, and 16 places in the Shefa province in Vanuatu, so I think you'll find a place near you.
Make a table where the weather for each of the cities are listed, for the coming ten 6-hour periods. The cities should be listed in the order above (first an Asian city, then an African city ...).
The information that should be listed is:
- City:
Name, CC
(CC
is the first two letters of the country name) - Time:
yyyy-mm-dd
- Period:
1
- Weather:
Cloudy
- Temperature:
24
The output format has the following restrictions:
The order is given as below (Time, Period, Weather, Temperature, Weather Temperature, Weather, Temperature ...). The city name and country code are headers
Kyoto, JA Addis Ababa, ET Minneapolis, US Rio de Janeiro, BR Genoa, IT Perth, AU
2015-11-05, 3, Cloudy, 15 Clear sky, 18 Heavy rain, 24 Cloudy, 12 Fair, 14 Rain, 26
2015-11-06, 0, Cloudy, 12 Fair, 14 Rain, 26 Cloudy, 12 Fair, 14 Rain, 26
2015-11-06, 1, Heavy rain, 14 Clear sky, 17 Rain, 22 Heavy rain, 14 Clear sky, 17 Rain, 22
2015-11-06, 2, Rain, 15 Clear sky, 12 Rain, 25 Heavy rain, 14 Clear sky, 17 Rain, 22
2015-11-06, 3, Partly cloudy, 9 Fair, 8 Heavy rain, 30 Clear sky, 8 Fair, 14 Partly cloudy, 25
2015-11-07, 1, Clear sky, -8 Fair, 14 Partly cloudy, 25 Clear sky, 8 Fair, -14 Partly cloudy, 25
2015-11-07, 2, Fog, 13 Partly cloudy, 15 Fair, 22 Clear sky, 8 Fair, 14 Partly cloudy, 25
The weather forecast can be found on www.yr.no. The weather data can be found on xml-format on urls such as:
http://www.yr.no/place/Australia/Western_Australia/Perth/forecast.xml
http://www.yr.no/place/Italy/Liguria/Genoa/forecast.xml
http://www.yr.no/place/Turks_and_Caicos_Islands/Other/Cockburn_Town/forecast.xml
http://www.yr.no/place/Bahamas/San_Salvador_and_Rum_Cay/Cockburn_Town/forecast.xml
Yes, there are apparently two places called "Cockburn Town". You can search for places on the main page (yr.no), and simply append /forecast.xml
when you've found your place. (You can select language in the top right corner, the website might be shown in Norwegian).
The data has the following format:
<time from="2015-11-05T19:00:00" to="2015-11-06T00:00:00" period="3">
<!--
Valid from 2015-11-05T19:00:00 to 2015-11-06T00:00:00
-->
<symbol number="4" numberEx="4" name="Cloudy" var="04"/>
<precipitation value="0" minvalue="0" maxvalue="0.4"/>
<!-- Valid at 2015-11-05T19:00:00 -->
<windDirection deg="131.5" code="SE" name="Southeast"/>
<windSpeed mps="3.7" name="Gentle breeze"/>
<temperature unit="celsius" value="12"/>
<pressure unit="hPa" value="1014.2"/>
</time>
<time from="2015-11-06T00:00:00" to="2015-11-06T06:00:00" period="0">...</time>
<time from="2015-11-06T06:00:00" to="2015-11-06T12:00:00" period="1">...</time>
As you can see, each 6 hour period has a period number "0", "1", "2" or "3". The table must have the date followed by the period number, 2015-11-06, 3
(might be separated by a comma, tab or whatever).
You must, for each of the periods list what type of weather it is, and the temperature, in this case: Cloudy, 12
(not 12 Cloudy
). The values can be separated by a comma, tab, or whatever.
Each city must be separated from the others in such a way that they form distinct "blocks", as in the example output. The output should be on a table like format.
The details of the output format is optional.
These parts: Italy/Liguria/Genoa/
, Brazil/Rio_de_Janeiro/Rio_de_Janeiro/
of the code can be subtracted from the byte count (no need to chose the shortest city names). Url-shorteners are prohibited.
It must be possible to run your code a year from now, so you can't hard code dates etc.
The weather data is free and publicly available, as long as the following attribution is shown, so please include it in the bottom of your answer.
This is code golf, so the shortest answer in bytes win.
Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK.
6
if (I_am_camping()) return "Heavy rain";
– LegionMammal978 – 2015-11-07T12:06:57.9537
if (I_am_at_work()) return "Clear sky";
– Stewie Griffin – 2015-11-07T12:13:30.8271
if(is_in_Ireland()) return "Slightly rainy, 54 degrees Fahrenheit
– Conor O'Brien – 2015-11-12T19:12:38.160