-
-
Save ravivmg/0278ac17e2bff1ea0d4d to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
#arguments for this program should be the list of years that you want to import (e.g. sh inputPatents.sh 2001 2002) | |
wget -r -H -l1 -np -nd -P google --reject=txt,css,html,js --wait=3 http://www.google.com/googlebooks/uspto-patents-applications-biblio.html | |
rm 'google/*.txt' | |
rm 'google/*.css' | |
rm 'google/*.js' | |
rm 'google/*.html' | |
for file in google/*.zip* ; do mv $file `echo $file | sed 's/\(.*\.\)zip\(.*\)/\1zip/'` ; done | |
for var in "$@" | |
do | |
mkdir -p "google/$var" | |
echo "*ab$var*.xml" | |
unzip "google/*ab$var*.zip" -d google | |
awk -v outputname="google/$var/output_" '/<?xml\ version=\"1.0\"(\ encoding=\"UTF\-8\")?\?>/{if (n) close(output); output=outputname n++ ".xml"} n {print >> output }' google/*ab$var*.xml | |
$EXIST_HOME/bin/client.sh -ouri=xmldb:exist:// -m /db/patents/applications/$var -p `pwd`/google/$var | |
rm -rf "google/$var" | |
rm "google/*.xml" | |
rm "google/*.txt" | |
rm "google/*.html" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment