|
| Recent
Articles |

Help, My Script Isn't Working! Here's a list of tips and tricks to consult at two a.m. when you're trying to put your site to bed and that d*mn script just won't work. 1. Make a note of the error message, and type it in Google. Leave out your unique paths and file names. Someone else has had the same problem...
Perl Loop Causes Strange Read-only Error Ok, folks: I don't understand this. It must have something to do with anonymous arrays in Perl (no, it doesn't, I realize now), but I don't grok the connection. I ran into this in attempting a seemingly simple change in some customer's code; it wasn't hard to fix...
Whatever, Perl 6 Is On The Way Larry Wall's recent State of the Onion address concerned Perl 6 and the concept of being prepared to do "whatever" in the context of the next version of the language. Government Computer News compared Perl 6 to "the ever-M.I.A. Duke Nukem computer game," and...
The Hidden Loop Programmers use loops to avoid writing repetitive code, but sometimes forget that compilers will unroll their loops when possible for efficiency. You can unroll your own loops, too. Rather than testing and branching takes time; if you need flat out performance, you avoid...
Webmin, Usermin Need Updates The French Security Incident Response Team (FrSIRT) has reported a pair of vulnerabilities in Webmin and Usermin that could be exploited by remote attackers. FrSIRT said in its advisory that the pair of flaws pose problems for users of the Webmin and Usermin web...
Seeing Perl In Google Code Google's release of a code repository for open source projects has a number of languages represented, including Perl. Perl -- It's like Java, only it lets you deliver on time and under budget. -- quote seen on Perl.org. Ever since Google opened up its Project...
Perl Plus Jifty Equals Hiveminder Yes, Jifty is another web application builder, and yes, Hiveminder is another to-do list; but it is Perl that made them possible. A post by Jesse Vincent at UsePerl announced the public debut of Hiveminder. The site has been quietly online for a while, and is ready for...
|
|
12.19.06
Handling Missing Data
By
A.P. Lawrence
I have an old Perl project that goes out to a Government web site, ftp's some files, massages them in various ways, and spits out some output. Over time, the project grew, and now does more than it used to.
To keep it generic and simple, let's pretend that originally it went out and got "temperature" files every hour. That was simple enough: about the only error condition would be the inability to get one or more of the files it wanted. My program simply kept track of what it actually got and only ran the rest of the process on new files.
The section of code that does that isn't hard:
Well, then "precipitation" was added, and then each file might have processing for different "customers". A bit of extra looping, no big deal.. but sometimes we'd get a "short file" output.
Examination of logs revealed the problem: every now and then a "temperature" file would be unavailable at the ftp site, so the final output only contained "precipitation" data. From my point of view, that's perfectly reasonable: the data wasn't available at the input, so it's not in the output.
But the customer doesn't like this. "Fix it", they said (well, much more pleasantly, but effectively that). So the question I put back to them is "How?". In this situation, there are really several possibilities: we could:
Leave it as it is now. I guess that doesn't count toward "fixing it".
Don't publish the file if it is "short". That ignores the data that we were able to get; but if the ultimate result is pointless without ALL of it, then this makes sense.
Fill the missing slots with data tagged as "bad". That might be reasonable too, because sometimes data we do get is tagged that way already.
Use an older "temperature" file - these things get published every hour, so we could produce a complete file using older data - I don't know if that makes sense to the final consumer, but we could do that. If acceptable, the next question would be "how old is still acceptable?"
Programmers have to deal with stuff like this any time there is a possibility of missing inputs. I talked previously about missing fields in a tab delimited file at Handling missing data in inputs; this is a slightly different example.
*Originally published at APLawrence.com
|