Modify Outlook export profile for Radium, per RT#74886
[sitka/sitka-tools.git] / marc_export_custom / stats-distribution.pl
CommitLineData
7716c3a7
RJ
1#!/usr/bin/perl
2use MARC::Batch;
3use strict;
4use warnings;
5my $batch = MARC::Batch->new( 'USMARC', @ARGV );
6$batch->strict_off();
7$batch->warnings_off();
8my %bibs;
9my %holdings;
10my $count_raw = 0;
11my $count_copies = 0;
12my $count_901c = 0;
13while ( my $marc = $batch->next ) {
14 $count_raw++;
15 my $field_901c = $marc->subfield(901,"c");
16 if(defined $field_901c) {
17 chomp $field_901c;
18 $count_901c++ if ($field_901c =~ /^.+$/);
19 }
20
21 my @field_852 = $marc->field(852);
22 my %holding_libs;
23 if(@field_852) {
24 FIELD852: foreach my $my852 (@field_852) {
25 my $my852b = $my852->subfield('b');
26 next FIELD852 unless (defined $my852b and $my852b =~ /^.+$/);
27 chomp $my852b;
28 $holdings{$my852b} = 0 unless exists($holdings{$my852b});
29 $holdings{$my852b}++;
30 $holding_libs{$my852b} = 1;
31 }
32 }
33 foreach(keys %holding_libs) {
34 $bibs{$_} = 0 unless exists($bibs{$_});
35 $bibs{$_}++;
36 }
37}
38
39foreach my $lib (sort keys %bibs) {
40 printf("bibs,%s,%d\n",$lib,$bibs{$lib});
41}
42foreach my $lib (sort keys %holdings) {
43 printf("copies,%s,%d\n",$lib,$holdings{$lib});
44 $count_copies += $holdings{$lib};
45}
46
47printf "summary,distinct-bibs-raw,%d\n",$count_raw;
48printf "summary,distinct-bibs-901c,%d\n",$count_901c;
49printf "summary,distinct-copies,%d\n",$count_copies;
50
51
52# vim: ts=2 sw=2