blob: 9763ab5a4e812cd04ca646c15cecd6dabc5b8459 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#!/bin/bash
cd $(dirname $0)
DBNAME=${LIGA_PLAYERS_DB_NAME}
curl ${LIGA_BAZA_CSV} | iconv -f cp1250 -t utf8 | grep '^[0-9]' | sed 's/;[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/;T/g' | cut -d';' -f1-7,10-11 > baza.csv
mysql ${LIGA_MYSQL_CONNECTION_OPTS} --local-infile=1 $DBNAME -e "TRUNCATE players;
LOAD DATA LOCAL INFILE 'baza.csv'
REPLACE
INTO TABLE players
FIELDS TERMINATED BY ';' ENCLOSED BY '\"'
(ID, gname, sname, rank, loc1, flag1, loc2, flag2, info);
UPDATE players SET age = REPLACE(flag1, 'K', ''), sex = IF(POSITION('K' IN flag1), 'K', '');
UPDATE players SET flag1 = NULL;
"
rm baza.csv
|