forked from Vanuan/bocharov_edr_loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orgsupdater
executable file
·49 lines (41 loc) · 1.4 KB
/
orgsupdater
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
#!/bin/bash
function status(){
data_dir=data
mv $data_dir $data_dir.bak
mkdir $data_dir
cd $data_dir
echo -e "Downloading..."
url=https://data.gov.ua/dataset/b244f35a-e50a-4a80-b704-032c42ba8142/resource/b0476139-62f2-4ede-9d3b-884ad99afd08/download/15-ufop.zip
wget $url --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.19 Safari/537.36" $fname
fname='15-ufop.zip'
echo -e "Downloaded. Size: " `du -hs $fname`
echo -e "Extracting..."
unzip $fname
# 7z x -y $fname 15.1-EX_XML_EDR_UO.xml
# 7z x -y $fname 15.2-EX_XML_EDR_FOP.xml
echo -e "Extracted."
echo "Convertiong Orgs to UTF-8"
time iconv -f cp1251 15.1-EX_XML_EDR_UO.xml > UO.xml.utf8
echo "Convertiong FOPs to UTF-8"
time iconv -f cp1251 15.2-EX_XML_EDR_FOP.xml > FOP.xml.utf8
echo "Converting UO file to multy line"
if [ 1 -eq `wc -l <UO.xml.utf8` ];
then
echo "File has one line, again... So we just use sed command!"
sed -i -e "s/<RECORD>/\n<RECORD>/g" UO.xml.utf8
fi
echo "Converting FOP file to multy line"
if [ 1 -eq `wc -l <FOP.xml.utf8` ];
then
echo "File has one line, again... So we just use sed command!"
sed -i -e "s/<RECORD>/\n<RECORD>/g" FOP.xml.utf8
fi
# echo "mode tag </DATA> to new line"
sed -i -e "s/<\/DATA>/\n<\/DATA>/g" UO.xml.utf8
sed -i -e "s/<\/DATA>/\n<\/DATA>/g" FOP.xml.utf8
cd -
}
status
echo "Parsing data"
time ./parseuo.py
echo 'done'