Lines 1-12
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
#----------------------------------- |
2 |
#----------------------------------- |
3 |
# Copyright 2013 ByWater Solutions |
3 |
# Copyright 2015 ByWater Solutions |
4 |
# |
4 |
# |
5 |
# This file is part of Koha. |
5 |
# This file is part of Koha. |
6 |
# |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it under the |
7 |
# Koha is free software; you can redistribute it and/or modify it under the |
8 |
# terms of the GNU General Public License as published by the Free Software |
8 |
# terms of the GNU General Public License as published by the Free Software |
9 |
# Foundation; either version 2 of the License, or (at your option) any later |
9 |
# Foundation; either version 3 of the License, or (at your option) any later |
10 |
# version. |
10 |
# version. |
11 |
# |
11 |
# |
12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
Lines 36-42
use C4::Biblio;
Link Here
|
36 |
use C4::Koha qw( GetVariationsOfISBN ); |
36 |
use C4::Koha qw( GetVariationsOfISBN ); |
37 |
use Koha::Database; |
37 |
use Koha::Database; |
38 |
|
38 |
|
39 |
binmode STDOUT, ':utf8'; |
39 |
binmode STDOUT, ':encoding(UTF-8)'; |
40 |
|
40 |
|
41 |
BEGIN { |
41 |
BEGIN { |
42 |
|
42 |
|
Lines 46-51
BEGIN {
Link Here
|
46 |
eval { require "$FindBin::Bin/../kohalib.pl" }; |
46 |
eval { require "$FindBin::Bin/../kohalib.pl" }; |
47 |
} |
47 |
} |
48 |
|
48 |
|
|
|
49 |
my $help; |
50 |
my $confirm; |
51 |
my $test; |
49 |
my $file; |
52 |
my $file; |
50 |
my $verbose; |
53 |
my $verbose; |
51 |
my $start; |
54 |
my $start; |
Lines 56-61
my $subfield_source = "b";
Link Here
|
56 |
my $subfield_source_value = "Lexile"; |
59 |
my $subfield_source_value = "Lexile"; |
57 |
|
60 |
|
58 |
GetOptions( |
61 |
GetOptions( |
|
|
62 |
'h|help' => \$help, |
63 |
'c|confirm' => \$confirm, |
64 |
't|test' => \$test, |
59 |
'f|file=s' => \$file, |
65 |
'f|file=s' => \$file, |
60 |
'v|verbose+' => \$verbose, |
66 |
'v|verbose+' => \$verbose, |
61 |
's|start=s' => \$start, |
67 |
's|start=s' => \$start, |
Lines 73-88
import_lexile.pl -f /path/to/LexileTitles.txt
Link Here
|
73 |
|
79 |
|
74 |
This script takes the following parameters : |
80 |
This script takes the following parameters : |
75 |
|
81 |
|
76 |
-f | --file CSV file of lexile scores ( acquired from Lexile.com ) |
82 |
-h --help Display this help |
77 |
-v | --verbose Print data on found matches |
83 |
-c --confirm Confirms you want to really run this script ( otherwise print help ) |
|
|
84 |
-t --test Runs the script in test mode ( no changes will be made to your database ) |
85 |
-f --file CSV file of lexile scores ( acquired from Lexile.com ) |
86 |
-v --verbose Print data on found matches |
78 |
--field Defines the field number for the Lexile data ( default: 521 ) |
87 |
--field Defines the field number for the Lexile data ( default: 521 ) |
79 |
--target-audience-note Defines the subfield for the lexile score ( default: a ) |
88 |
--target-audience-note Defines the subfield for the lexile score ( default: a ) |
80 |
--source Defines the "Source" subfield ( default: b ) |
89 |
--source Defines the "Source" subfield ( default: b ) |
81 |
--source-value Defines the value to put stored in the "Source" subfield ( default: "Lexile" ) |
90 |
--source-value Defines the value to put stored in the "Source" subfield ( default: "Lexile" ) |
82 |
|
91 |
|
|
|
92 |
The CSV file must have the following columns ( with the first line being the column headers ) in tab delimited format: |
93 |
Title, Author, ISBN, ISBN13, Lexile |
94 |
|
83 |
ENDUSAGE |
95 |
ENDUSAGE |
84 |
|
96 |
|
85 |
unless ($file) { |
97 |
if ( $help || !$file || !$confirm ) { |
86 |
say $usage; |
98 |
say $usage; |
87 |
exit(1); |
99 |
exit(1); |
88 |
} |
100 |
} |
Lines 188-194
while ( my $row = $csv->getline_hr($fh) ) {
Link Here
|
188 |
$record->append_fields($field); |
200 |
$record->append_fields($field); |
189 |
} |
201 |
} |
190 |
|
202 |
|
191 |
ModBiblio( $record, $biblionumber ); |
203 |
ModBiblio( $record, $biblionumber ) unless ( $test ); |
192 |
} |
204 |
} |
193 |
|
205 |
|
194 |
} |
206 |
} |
195 |
- |
|
|