# # Handling missing data
APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Handling missing data

I've removed advertising from most of this site and will eventually clean up the few pages where it remains.

While not terribly expensive to maintain, this does cost me something. If I don't get enough donations to cover that expense, I will be shutting the site down in early 2020.

If you found something useful today, please consider a small donation.



Some material is very old and may be incorrect today

© December 2006 Anthony Lawrence

2006/12/14

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:


    foreach(@file_to_get) {
    $newerr=0;
    $ftp->get($f,$f) or $newerr=1;
    push @gotfiles, "$f" if not $newerr;
    }
    
       foreach(@gotfiles) {
          ...
    }
 

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:


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.


If you found something useful today, please consider a small donation.



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> Handling missing data


Inexpensive and informative Apple related e-books:

Take Control of Parallels Desktop 12

Take Control of Numbers

Take Control of Apple Mail, Third Edition

Photos for Mac: A Take Control Crash Course

Are Your Bits Flipped?





More Articles by © Anthony Lawrence





Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us


Printer Friendly Version





You can't do it unless you can imagine it. (George Lucas)




Linux posts

Troubleshooting posts


This post tagged:

Code

Perl

Programming



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode