Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Remove array if data inconsistent

by jhourcle (Prior)
on Apr 22, 2009 at 14:59 UTC ( #759308=note: print w/ replies, xml ) Need Help??


in reply to Remove array if data inconsistent

It's not a direct answer to your question, which I think people have already commented on -- but once that you've pared down the list, you might want to consider making some sort of visualization of the line, so that you can quickly scan it visually and see what might be worth investigating further.

For the data that you're dealing with, I'd probably look at using sparklines -- there's a few CPAN modules to generate them.

Then, you can look at a page of graphs, and see which ones are stable / going up / random / etc.


Comment on Re: Remove array if data inconsistent
Re^2: Remove array if data inconsistent
by BJ_Covert_Action (Beadle) on Apr 22, 2009 at 16:16 UTC
    Along the same lines, you could always simply sort the different lines into two different output files if you are worried about record keeping. For instance, once you decide how you want to filter/screen the data (probably by one of the methods discussed in the previous posts) you could put a simple if-else check to send the 'consistent' data lines to a file named "good_data.csv" and the 'inconsistent' data lines to a file named "discarded_data.csv" (or whichever names you like) so that you can review the discarded data at a later time if need be, or recover any lines that were filtered incorrectly. This also might help you find any errors or bugs in you code later on as you test it more thoroughly.

    I am thinking something along these lines (pseudocode) (in case you aren't terribly familiar with syntax):

    open INPUT, "name_of_input_file" or die: $!; open GOOD_OUTPUT, ">good_data.csv" or die $!; open BAD_OUTPUT, ">discarded_data.csv" or die $!; while(my $line = <INPUT>){ chomp $line; if(data_meets_good_condition){ print GOOD_OUTPUT "$line\n"; }else{ print BAD_OUTPUT "$line\n"; } }

    That's a little rudimentary (and verbiose if you are a fan of golf) and needs an appropriate logical check in the if condition, but the primary idea is the if-else check, that way you don't totally wipe data by accident. Again, in terms of filtering the data, some of the methods discussed above are probably better.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://759308]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (16)
As of 2014-12-18 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (55 votes), past polls