Mercurial > hg > egg-tcls
changeset 377:0a6d9f0f0a57
fetch_weather: Fix Tiehallinto metadata handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 07 Feb 2016 17:53:33 +0200 |
parents | a30283d1f050 |
children | b706e8ebecf8 |
files | fetch_weather.pl |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/fetch_weather.pl Wed Feb 03 17:07:26 2016 +0200 +++ b/fetch_weather.pl Sun Feb 07 17:53:33 2016 +0200 @@ -323,7 +323,7 @@ if ($fetch_meta) { print STDERR "Fetching Tiehallinto static meta data.\n" if (opt_get_int("debug") > 0); - my $uri = "https://raw.githubusercontent.com/finnishtransportagency/metadata/master/csv/meta_traffic_stations.csv"; + my $uri = "https://raw.githubusercontent.com/finnishtransportagency/metadata/master/csv/meta_rws_stations.csv"; my $res = fetch_http($uri); die("Failed to fetch $uri data.\n") unless ($res->code <= 200 && $res->code <= 201); @@ -339,8 +339,8 @@ # Parse the data .. my $meta_data = {}; -# my $csv = Text::CSV->new({blank_is_undef => 1, decode_utf8 => 1}); - my $csv = Text::CSV->new({blank_is_undef => 1}); + my $csv = Text::CSV->new({blank_is_undef => 1, decode_utf8 => 1, sep_char => ";"}); +# my $csv = Text::CSV->new({blank_is_undef => 1}); die("Failed to instantiate Text::CSV object?\n") unless defined($csv); foreach my $line (split(/\s*\n\s*/, $meta_str)) @@ -350,7 +350,7 @@ my @fields = $csv->fields(); if (scalar(@fields) > 1) { - $$meta_data{$fields[1]} = \@fields; + $$meta_data{$fields[0]} = \@fields; } } } @@ -375,6 +375,10 @@ plonk_data($wdata->{"averagewindspeed"}), ]; } + else + { + print STDERR "Station ID #".$wid." not defined?\n"; + } } print STDERR $nrecords." records from Tiehallinto.\n" if (opt_get_int("debug") > 0); }