-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_IAEA_data.sh
73 lines (62 loc) · 1.54 KB
/
get_IAEA_data.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# . get_IAEA_data.sh 2018 OPEX-2019CD
# http://www-pub.iaea.org/MTCD/Publications/PDF/OPEX-2019CD.zip
# . get_IAEA_data.sh 2017 P1828_OPEX_CD_web
# . get_IAEA_data.sh 2016 P1792_OPEX_CD_web
# . get_IAEA_data.sh 2015 P1752_OPEX_CD_web
outputFilePath="IAEA/"
# create IAEA folder if not present
if [ ! -d "$outputFilePath" ]; then
mkdir $outputFilePath
fi
cd $outputFilePath
if [ "$1" == "" ]
then
# Default setting
# 2017 DATA - 2018 Edition
YEAR = "2017"
ARCHIVE="P1828_OPEX_CD_web"
else
YEAR="$1"
ARCHIVE="$2"
fi
URL="https://www-pub.iaea.org/MTCD/Publications/PDF/"$ARCHIVE".zip"
# create a folder for the YEAR, if not present
if [ ! -d "$YEAR" ]; then
mkdir $YEAR
fi
cd $YEAR
if [ -f $ARCHIVE".zip" ]
then
echo $YEAR" data was already stored."
else
# get 2017 data
wget $URL
# unpack
unzip $ARCHIVE".zip" -d $ARCHIVE
fi
# convert to text
# should it be less than of equal to?
if [ "$YEAR" == "2018" ]
then
filename="OPEX-"$(expr $YEAR + 1)"-edition_rev"
input=$ARCHIVE"/PDF/"$filename".pdf"
output=$ARCHIVE"/PDF/OPEX_"$(expr $YEAR + 1)"_edition.txt"
elif [ "$YEAR" == "2015" ]
then
filename="OPEX_"$(expr $YEAR + 1)""
input=$ARCHIVE"/PDF/"$filename".pdf"
output=$ARCHIVE"/PDF/"$filename"_edition.txt"
else
filename="OPEX_"$(expr $YEAR + 1)"_edition"
input=$ARCHIVE"/PDF/"$filename".pdf"
output=$ARCHIVE"/PDF/"$filename".txt"
fi
# Also check the input and unzip if missing
if [ -f $output ]
then
echo "A file with the same name is already available: "$output
else
pdftotext $input $output
fi
cd ../..