changeset 343:3fff571a904b

fetch_weather: Some fixes to make this actually work.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 04 Oct 2015 14:34:03 +0300
parents 8212fe58da45
children 25fc5a2b42ae
files fetch_weather.pl
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/fetch_weather.pl	Sun Oct 04 14:24:42 2015 +0300
+++ b/fetch_weather.pl	Sun Oct 04 14:34:03 2015 +0300
@@ -318,10 +318,11 @@
 
       # 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});
+      die("Failed to instantiate Text::CSV object?\n") unless defined($csv);
       foreach my $line (split(/\s*\n\s*/, $meta_str))
       {
-        if ($csv->parse($line))
+        if (defined($line) && $csv->parse($line))
         {
           my @fields = $csv->fields();
           $$meta_data{$fields[1]} = \@fields;
@@ -338,7 +339,7 @@
           {
             $weatherdata->{$meta_data->{$wid}[3]} =
             [
-              0,
+              1,
               str2time(plonk_data($wdata->{"measurementtime"}{"utc"})),
               plonk_data($wdata->{"airtemperature1"}),