-
Notifications
You must be signed in to change notification settings - Fork 0
/
database_to_csv.sh
executable file
·59 lines (52 loc) · 1.4 KB
/
database_to_csv.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
export PYTHONPATH=${HOME}/svn/norut/uav/trunk/
FOLDER=${HOME}/Desktop/mysql/
usage() {
echo "Usage"
echo "-d | --date to set date (dd-mm-yyyy), defaults to today"
echo "-e | --endtime to set endtime (default 23:59:59)"
echo "-h | --help to display usage"
echo "-s | --starttime to set starttime (default 00:00:00)"
echo "-v | --verbose to show python command"
echo "-z | --zeroed to normalize timestamps to start at zero"
}
ENDTIME="23:59:59"
STARTTIME="00:00:00"
VERBOSE=false
ZEROED=""
DATE=`date +%d-%m-%Y`
while [ "$1" != "" ]; do
case $1 in
-d | --date ) DATE=$2;
shift
;;
-e | --endtime ) ENDTIME=$2;
shift
;;
-h | --help ) usage
exit 0
;;
-s | --starttime ) STARTTIME=$2;
shift
;;
-v | --verbose ) VERBOSE=true
;;
-z | --zeroed ) ZEROED=" -z"
;;
* ) echo "You are not doing it right..;)"
usage
exit 1
esac
shift
done
FILEDATE=`date +%Y%m%d`
FILE=${FILEDATE}_${STARTTIME}
if [ ! -z "$ZEROED" ]; then
FILE="${FILE}_z"
fi
FILEPATH=${FOLDER}${FILE}.csv
STARTDATETIME="${STARTTIME}_${DATE}"
ENDDATETIME="${ENDTIME}_${DATE}"
if $VERBOSE; then
set -v
fi
python -m src.tools.mysql_to_csv -d uav -f ${FILEPATH} -c Network.Dispersy -s ${STARTDATETIME} -e ${ENDDATETIME} $ZEROED