forked from publiux/parseCifp
-
Notifications
You must be signed in to change notification settings - Fork 3
/
parseCifp.sh
executable file
·46 lines (35 loc) · 1.23 KB
/
parseCifp.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
#!/bin/bash
set -eu # Always put this in Bourne shell scripts
IFS=$(printf '\n\t') # Always put this in Bourne shell scripts
#Check count of command line parameters
if [ "$#" -ne 1 ] ; then
echo "Usage: $0 <path to local cifp file>" >&2
echo "eg. $0 ./www.aeronav.faa.gov/Upload_313-d/cifp/cifp_201704.zip" >&2
echo "please run ./freshen_local_cifp.sh to update local CIFP data files first" >&2
exit 1
fi
sourceZip="$1"
if [ ! -f "$sourceZip" ]; then
echo "$sourceZip doesn't exist" >&2
echo "please run ./freshen_local_cifp.sh to update local CIFP data files" >&2
exit 1
fi
# Process the supplied file name to get cycle number
# Save everything after 'cifp_20'
tmp=${sourceZip#*cifp_20}
# Remove the extension, leaving the cycle number
cycle=${tmp%.*}
# Where the CIFP data is unzipped to
datadir=./CIFP_20$cycle/
# Where to save files we create
outputdir=.
echo "Unzipping CIFP $cycle files"
unzip -u -j -q "$sourceZip" -d "$datadir" > "$cycle-unzip.txt"
# Delete any existing files
rm -f $outputdir/cifp-"$cycle".db
echo "Creating the database"
# Create the sqlite database
./parseCifp.pl -c"$cycle" "$datadir"
# Add indexes
echo "Adding indexes"
sqlite3 $outputdir/cifp-"$cycle".db < addIndexes.sql