-
Notifications
You must be signed in to change notification settings - Fork 6
/
load-data.sh
16 lines (14 loc) · 1.08 KB
/
load-data.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
CURRDIR=$(pwd)
for i in $CURRDIR/data/*.zip; do
unzip -o $i -d $CURRDIR/data
find $CURRDIR/data -iname drug*.txt | xargs -I % sudo -u postgres psql faers -c "copy drug from '"%"' with header csv delimiter E'$'"
find $CURRDIR/data -iname demo*.txt | xargs -I % sudo -u postgres psql faers -c "copy demo from '"%"' with header csv delimiter E'$'"
find $CURRDIR/data -iname indi*.txt | xargs -I % sudo -u postgres psql faers -c "copy indi from '"%"' with header csv delimiter E'$'"
find $CURRDIR/data -iname outc*.txt | xargs -I % sudo -u postgres psql faers -c "copy outc from '"%"' with header csv delimiter E'$'"
find $CURRDIR/data -iname rpsr*.txt | xargs -I % sudo -u postgres psql faers -c "copy rpsr from '"%"' with header csv delimiter E'$'"
find $CURRDIR/data -iname ther*.txt | xargs -I % sudo -u postgres psql faers -c "copy ther from '"%"' with header csv delimiter E'$'"
find $CURRDIR/data -iname reac*.txt | xargs -I % sudo -u postgres psql faers -c "copy reac from '"%"' with header csv delimiter E'$'"
rm -rf $CURRDIR/data/ascii
rm $CURRDIR/data/*.pdf
done