changeset 354:de411e7834aa

fetch_weather: Reload old data from stored data.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 Dec 2015 22:37:53 +0200
parents a52a983c0c14
children a74cb8a1abf5
files fetch_weather.pl
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/fetch_weather.pl	Fri Dec 11 22:19:21 2015 +0200
+++ b/fetch_weather.pl	Fri Dec 11 22:37:53 2015 +0200
@@ -276,6 +276,27 @@
 
 
 ###
+### Load already cached data
+###
+if (opt_chk_valid("outfile", 1))
+{
+  my $str = read_file(opt_get("outfile"), binmode => ':utf8', err_mode => 'quiet');
+  if (defined($str))
+  {
+    foreach my $line (split(/\s*\n\s*/, $str))
+    {
+      my @mtmp = split(/\|/, $line);
+      if (scalar(\@mtmp) >= 4)
+      {
+        $weatherdata->{shift @mtmp} = \@mtmp;
+      }
+    }
+    print STDERR scalar(keys %$weatherdata)." old records reloaded.\n" if (opt_get_int("debug") > 0);
+  }
+}
+
+
+###
 ### Fetch Tiehallinto data
 ###
 if (opt_chk_bool("opt_tiehallinto"))