Skip to content

Commit fabc5ad

Browse files
committed
handle no .shp file scenario
1 parent 19bdf0b commit fabc5ad

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

cityscrape-setup.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ fi
3131
pip install beautifulsoup4==4.4.0
3232
pip install requests==2.7.0
3333

34-
echo "Cityscrape setup complete!"
34+
# echo "Cityscrape setup complete!"
35+
36+
sudo -u postgres psql

run-cityscrape-postgresql-ingest.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,31 @@ pushd $OUTPUT_DIR
1010
echo "Unzipping files..."
1111
unzip -f "*.zip"
1212

13-
for f in *.shp
14-
do
15-
echo "Loading "$f
16-
17-
ogr2ogr -overwrite -progress -skipfailures -f "PostgreSQL" PG:"host=localhost user=postgres dbname=city" $f#
13+
if [ -z "$(ls *.shp)" ]
14+
then
15+
echo "No *.shp files found, exiting..."
16+
break
17+
else
18+
for f in *.shp
19+
do
20+
echo "Loading "$f
1821

19-
done
22+
ogr2ogr -overwrite -progress -skipfailures -f "PostgreSQL" PG:"host=localhost user=postgres dbname=city" $f#
2023

24+
done
25+
fi
2126

2227
for f in *.mdb
23-
do
24-
echo "Extracting tables from $f"
2528

26-
mdb-schema $f postgres | sed 's/Char/Varchar/g' | sed 's/Postgres_Unknown 0x0c/text/g' | psql -h localhost -U postgres -d city
29+
do
30+
echo "Extracting tables from $f"
31+
32+
mdb-schema $f postgres | sed 's/Char/Varchar/g' | sed 's/Postgres_Unknown 0x0c/text/g' | psql -h localhost -U postgres -d city
2733

28-
tables=$(echo -en $(mdb-schema $f postgres | grep "CREATE TABLE" | awk '{ print $3 }' | sed -e 's/"//g');)
34+
tables=$(echo -en $(mdb-schema $f postgres | grep "CREATE TABLE" | awk '{ print $3 }' | sed -e 's/"//g');)
2935

3036
for i in $tables
37+
3138
do
3239
echo "[File: "$f" ] [Table - "$i"]"
3340

@@ -37,6 +44,6 @@ do
3744

3845
done
3946

40-
# return to project root $BASEDIR
47+
# # return to project root $BASEDIR
4148
popd
4249

0 commit comments

Comments
 (0)