Refbase update_2021-01-28_15_58
This commit is contained in:
42
contrib/endnote/README
Normal file
42
contrib/endnote/README
Normal file
@@ -0,0 +1,42 @@
|
||||
endnote2refbase
|
||||
===============
|
||||
|
||||
Author
|
||||
------
|
||||
Richard Karnesky <karnesky@gmail.com>
|
||||
|
||||
About
|
||||
-----
|
||||
This is an alternative to refbase's web-based import of Endnote data. It
|
||||
allows Endnote users to export a text file which can be imported into the
|
||||
refbase MySQL database.
|
||||
|
||||
Use
|
||||
---
|
||||
Part I: Endnote
|
||||
- Copy refbase.ens into your Endnote styles directory.
|
||||
On win32 systems, this is typically:
|
||||
C:\Program Files\Endnote\Styles
|
||||
On Mac systems, this is typically:
|
||||
Macintosh HD\Applications\EndNote #\Styles
|
||||
(where # corresponds to a version #)
|
||||
- Open the Endnote file you wish to import into refbase.
|
||||
- Choose the refbase Output Style
|
||||
- Export to 'endnote.txt'
|
||||
Part II: PHP [*]
|
||||
- Executing 'php endnote2mysql.php' will produce 'import.txt'
|
||||
('php' must be in your path or you should prefix it with the path to php)
|
||||
Part III: Check it!
|
||||
- As this is a preliminary script that has undergone little testing, it is
|
||||
suggested that you look at 'import.txt' in spreadsheet software.
|
||||
- New versions of Endnote dump UTF-8 data. You should be able to use this as
|
||||
is if you have a UTF-8 database. If you don't have a UTF-8 database, you
|
||||
should convert the file to the character encoding you do use (using iconv,
|
||||
recode, or <http://www.motobit.com/util/charset-codepage-conversion.asp>).
|
||||
Part IV: MySQL [*]
|
||||
- From within your MySQL command line interpreter (mysql -u root literature -p):
|
||||
LOAD DATA LOCAL INFILE "import.txt" INTO TABLE refs;
|
||||
|
||||
[*]If you are comfortable that the script works and are on a system with a POSIX
|
||||
shell (nearly all *nix, including OS X; Windows through Cygwin or similar),
|
||||
you may use Andreas Czerniak's en-importer.sh to automate Parts II-IV.
|
51
contrib/endnote/en-importer.sh
Normal file
51
contrib/endnote/en-importer.sh
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# EndNote - Importer to RefBase MySQL table
|
||||
#
|
||||
# Andreas Czerniak <ac@oceanlibrary.org>
|
||||
#
|
||||
# initial: 05-11-2005
|
||||
#
|
||||
# modified:
|
||||
# 2005-12-11 ; ac ; clean up static codes
|
||||
# 2005-12-15 ; rk ; remove "v.9", import into CVS
|
||||
# 2006-01-03 ; ac ; replace LOAD DATA INTO statement with mysqlimport - Thx. Matthias Steffens <refbase@extracts.de>
|
||||
#
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Which endnote file ?"
|
||||
echo -e "\nusage: $0 endnote.file [database [mysql-options] ]\n"
|
||||
exit 127
|
||||
fi
|
||||
|
||||
ENFILE=$1
|
||||
|
||||
MYSQLDB=$2 || MYSQLDB="literature" # default: literature
|
||||
MYSQLOPTION=$3 || MYSQLOPTION="-p" # default: with password
|
||||
|
||||
if [ ! -d imported ] ; then
|
||||
mkdir imported
|
||||
fi
|
||||
|
||||
./endnote2mysql.php $1
|
||||
|
||||
if [ ! -f import.txt ] ; then
|
||||
echo "endnote2mysql convert failed !"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mv import.txt refs.txt
|
||||
mysqlimport --local $MYSQLOPTION $MYSQLDB "refs.txt" > sqloutput.txt
|
||||
|
||||
cat sqloutput.txt
|
||||
|
||||
rm refs.txt
|
||||
rm sqloutput.txt
|
||||
|
||||
cat $ENFILE | tail
|
||||
|
||||
echo "\n\nrows imported: "
|
||||
cat $ENFILE | wc -l
|
||||
|
||||
mv $ENFILE imported/.
|
||||
|
63
contrib/endnote/endnote2mysql.php
Normal file
63
contrib/endnote/endnote2mysql.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// Project: Web Reference Database (refbase) <http://www.refbase.net>
|
||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
|
||||
// original author.
|
||||
//
|
||||
// This code is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
|
||||
// License for more details.
|
||||
//
|
||||
// File: ./contrib/endnote/endnote2mysql.php
|
||||
// Author: Richard Karnesky <mailto:karnesky@northwestern.edu>
|
||||
//
|
||||
// Created: 18-Mar-05, 17:10
|
||||
// Modified: 19-Mar-05, 13:50
|
||||
|
||||
// WARNING
|
||||
// This hasn't been tested extensively & can cause weirdness. Give the data
|
||||
// a once over in a spreadsheet to confirm it looks OK before import!!!
|
||||
|
||||
// This processes the text file produced by using refbase.ens in Endnote:
|
||||
// - Fixes linefeeds, which Endnote can't handle well:
|
||||
// - trims carriage returns
|
||||
// - replaces newlines with '\n'
|
||||
// - trims '<REFBASE>' from the start of each citation
|
||||
// - replaces '</REFBASE>' with a newline character
|
||||
// - Replaces '<REFBASE J/>' with 'Journal' (a Field Name in Endnote)
|
||||
// - Inserts '\N' between multiple tabs (to explicitly NULL empty fields)
|
||||
// - Replaces '<Go to ISI>://*\t' with '\N' (bad URLs in Endnote)
|
||||
|
||||
// TODO:
|
||||
// - Tabs within fields aren't replaced! This can screw things up!
|
||||
// - Allow people to change import & export filenames
|
||||
// - More fields (particularly all dates, first author, number of authors)
|
||||
// - Better parsing of current fields (correct use of 'ed' vs 'eds)
|
||||
// - Automatically import via mysql (intentionally unimplemented for safety)
|
||||
// - Deprecate this whole darn mess by adding native import facilities ;-)
|
||||
|
||||
$fin = file_get_contents('endnote.txt');
|
||||
if (!$fin) {
|
||||
echo "Error! Couldn't open endnote.txt.";
|
||||
}
|
||||
else {
|
||||
$fin = str_replace("\r","",$fin);
|
||||
$fin = str_replace("\n","\\n",$fin);
|
||||
$fin = str_replace("<REFBASE>","",$fin);
|
||||
$fin = str_replace("</REFBASE>\\n","\n",$fin);
|
||||
$fin = str_replace("<REFBASE J/>","Journal",$fin);
|
||||
$fin = preg_replace("/(?<=\t)(?=\t)/","\\N",$fin);
|
||||
$fin = preg_replace("/<Go to ISI>:\/\/\S*/","\\N",$fin);
|
||||
}
|
||||
do {
|
||||
if (!($fout = fopen('import.txt', "w"))) {
|
||||
$rc = 1; break;
|
||||
}
|
||||
if (!fwrite($fout, $fin)) {
|
||||
$rc = 2; break;
|
||||
}
|
||||
$rc = true;
|
||||
} while (0);
|
||||
if ($fout) {
|
||||
fclose($fout);
|
||||
}
|
||||
?>
|
BIN
contrib/endnote/refbase.ens
Normal file
BIN
contrib/endnote/refbase.ens
Normal file
Binary file not shown.
Reference in New Issue
Block a user