in reply to Re: Remove array if data inconsistent
in thread Remove array if data inconsistent
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.
|
|---|