Skip to content
Snippets Groups Projects
Commit 1c2665fa authored by Gerhard Gonter's avatar Gerhard Gonter :speech_balloon:
Browse files

script to extract data from eod_data.tsv to create a change report of UB

parent 4d63f0ff
Branches
No related tags found
No related merge requests found
#!/usr/bin/perl
use strict;
use Data::Dumper;
$Data::Dumper::Indent= 1;
use Util::Simple_CSV;
my $fnm_in= shift(@ARGV) || 'eod_data.tsv';
my $fnm_out= shift(@ARGV) || 'report_bib.tsv';
my @columns_copy= qw(ac_number mms_id ticket val_hdl);
my @columns_out= qw(ac_number mms_id alma_fetched ticket url nbn hdl val_hdl);
my $tsv_in= Util::Simple_CSV->new(load => $fnm_in, separator => "\t");
open (TSV_OUT, '>:utf8', $fnm_out) or die;
print TSV_OUT join("\t", @columns_out), "\n";
my $data= $tsv_in->{data};
# print __LINE__, " data: ", Dumper ($data);
foreach my $row (@$data)
{
# print __LINE__, " row: ", Dumper ($row);
my ($update_url, $update_urn, $update_hdl, $update_doi)= map { $row->{$_} } qw( update_phaidra_url update_urn update_hdl update_doi );
# printf ("update_url=[%s] update_urn=[%s] update_hdl=[%s] update_doi=[%s]\n", $update_url, $update_urn, $update_hdl, $update_doi);
if ($update_url || (0 && $update_urn) || $update_hdl)
{
my %out= map { $_ => $row->{$_} } @columns_copy;
$out{url}= $update_url if (defined ($update_url));
$out{nbn}= $update_urn if (defined ($update_urn));
$out{hdl}= $update_hdl if (defined ($update_hdl));
$out{alma_fetched}= $row->{ts_fetched};
$out{hdl}= $row->{hdl} unless ($row->{val_hdl} eq $row->{hdl}); # set handle only when not alreadys set...
# print __LINE__, " out: ", Dumper(\%out);
print TSV_OUT join("\t", map { $out{$_} } @columns_out), "\n";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment