Created
January 22, 2018 17:55
-
-
Save tomredsky/0d566926e3750c468b3cd3cc666291a6 to your computer and use it in GitHub Desktop.
ml dat fix-up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use v5.22; | |
use warnings; | |
=head1 NAME | |
mlrecords.pl | |
=head2 Description | |
Try and find ML records from the database as it was on 13st Oct 2017, where the | |
creation date (ml.dat) does not much the creation date on the current database. | |
We will not catch all the records with the wrong data but we will get 117. | |
=cut | |
use DateTime::Format::Pg; | |
use lib 'lib'; | |
use SPL::AppConfig 'schema_connect'; | |
my $schema = schema_connect(); | |
my ($in, $found); | |
while (<DATA>) { | |
s/\s+$//; | |
++$in; | |
my ($code, $date) = split(',', $_); | |
# There are a large number of companies in the current DB that | |
# do not exist in the DB on 2017-10-31 | |
next if ( !$date ); | |
#warn "Code $code has no date\n" and next if (!$date); | |
my $comp = $schema->companies->find( { cod => $code }); | |
my $parser = DateTime::Format::Pg->new(); | |
if ($comp) { | |
my $dt = $parser->parse_datetime($date); | |
if ($comp->dat->ymd ne $dt->ymd) { | |
say $comp->name . "\t" . $comp->dat->ymd() . "\t" . $dt->ymd(); | |
++$found; | |
#$comp->dat($dt->ymd); | |
} | |
} | |
} | |
say "$found of $in"; | |
__DATA__ | |
SMPOST00,2017-10-27 | |
IED00000,2017-10-30 | |
LORCUL00,2016-11-30 | |
SDELLS00,2017-10-31 | |
20119745,2017-02-09 | |
PGFLIM00,2017-04-06 | |
20127343,2017-10-27 | |
FACULD00,2017-10-30 | |
BRIJOU01,2012-10-18 | |
JONATH02,2017-10-30 | |
20124978,2017-07-31 | |
20127344,2017-10-27 | |
... | |
... | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment