forked from stuppie/semmed-biolink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemmed_sql_to_csv.sh
executable file
·87 lines (80 loc) · 2.39 KB
/
semmed_sql_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
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
#!/usr/bin/env bash
GUNZIP="/usr/bin/env gunzip"
SOURCE=
TARGET=
DATA_PATH=./data/
echo
echo "Converting Semantic Medline Database SQL to CSV..."
echo
PS3='Please enter your choice of table to convert: '
options=("Predication" "Citations" "Predication Aux" "Sentence" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Predication")
echo
echo "Predication Data"
SOURCE=${SEMMEDDB_PREDICATION_ARCHIVE}
TARGET=${SEMMEDDB_PREDICATION_CSV}
# prepend table column names
cp predication_table_col_names_2020.txt ${TARGET}
break
;;
"Citations")
echo
echo "Citations Auxiliary Data"
SOURCE=${SEMMEDDB_CITATIONS_ARCHIVE}
TARGET=${SEMMEDDB_CITATIONS_CSV}
# prepend table column names
cp citations_table_col_names_2020.txt ${TARGET}
break
;;
"Predication Aux")
echo
echo "Predication Auxiliary Data"
SOURCE=${SEMMEDDB_PREDICATION_AUX_ARCHIVE}
TARGET=${SEMMEDDB_PREDICATION_AUX_CSV}
# prepend table column names
cp predication_aux_table_col_names_2020.txt ${TARGET}
break
;;
"Sentence")
echo
echo "Sentence Data"
SOURCE=${SEMMEDDB_SENTENCE_ARCHIVE}
TARGET=${SEMMEDDB_SENTENCE_CSV}
# prepend table column names
cp sentence_table_col_names_2020.txt ${TARGET}
break
;;
"Quit")
exit 0
;;
*) echo "invalid option $opt";;
esac
done
echo
if [[ -z ${TARGET} ]]; then
echo 'Target file path not yet specified: execute the "setup_environment.sh" script before running this script!'
exit 0
fi
echo "Converting '${SOURCE}' to '${TARGET}' in folder '${DATA_PATH}'"
echo
echo "Do you wish to continue with this conversion?"
echo
PS3='Please choose (1 or 2): '
select yn in "Yes" "No"; do
case $yn in
Yes )
echo;
${GUNZIP} -c ${DATA_PATH}${SOURCE} | python3 mysqldump_to_csv.py >> ${DATA_PATH}${TARGET}
break;;
No )
echo
echo "OK... I abort the conversion... come again soon!"
exit 0;;
*) echo "Please select option 1 (Yes) or 2 (No)";;
esac
done
echo
echo "Processing completed!"