-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.sh
executable file
·129 lines (100 loc) · 2.66 KB
/
loader.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
#set environment variable for pg latin to work in current session
export PGCLIENTENCODING=latin1
DATA_PATH=/tmp/1map
if [ -n "$1" ]
then
DATA_PATH=$1
fi
#we assume functions.sh is also in the base directory where you have the loading script
source functions.sh
cd ${DATA_PATH}
#load all the zipped files into the database
#load all files within folders like 2229
for file in `ls *.zip`; do
echo ${file};
if [[ ${#file} -eq 8 ]]; then
echo "file is 8 char long"
unzip ${file}
cd ${PWD}/${file%.*}
rm *metadata*
remove_first_five_characters
remove_ITIS50V_characters
remove_other_char
remove_character_v
remove_character_0
remove_character_a
remove_character_ab
remove_last_underscore
remove_dates
remove_numbers
lowercase
load_shp
cd ..
cd ${DATA_PATH}
#load all files within folders like 2930_prj
elif [[ ${#file} -eq 12 ]]; then
echo "12 character long ${file}"
unzip ${file}
cd ${PWD}/${file%.*}
rm *metadata*
remove_first_character
remove_first_five_characters
remove_ITIS50V_characters
remove_other_char
remove_character_v
remove_character_0
remove_character_a
remove_character_ab
remove_last_underscore
remove_dates
remove_numbers
lowercase
load_shp
cd ..
cd ${DATA_PATH}
#load all files within folders like 2930_2426
elif [[ ${#file} -eq 13 ]]; then
echo "13 characters long"
unzip ${file}
cd ${PWD}/${file%.*}
rm *metadata*
renaming_merged_blocks
remove_ITIS50V_characters
remove_other_char
remove_character_v
remove_character_0
remove_character_a
remove_character_ab
remove_last_underscore
remove_dates
remove_numbers
lowercase
load_shp
cd ..
cd ${DATA_PATH}
#load all files within folders like 2930_2426_prj
elif [[ ${#file} -eq 17 ]]; then
echo "17 characters"
unzip ${file}
cd ${PWD}/${file%.*}
rm *metadata*
remove_first_character
renaming_merged_blocks
remove_ITIS50V_characters
remove_other_char
remove_character_v
remove_character_0
remove_character_a
remove_character_ab
remove_last_underscore
remove_dates
remove_numbers
lowercase
load_shp
cd ..
cd ${DATA_PATH}
fi
done
cd ${DATA_PATH}
echo "Finito"