Last active
February 19, 2023 12:46
-
-
Save dgadiraju/ce1ccf641911c5d6cb414a0b06b93a06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE nyse; | |
CREATE USER 'nyse_user' IDENTIFIED BY 'itversity'; | |
GRANT ALL ON nyse.* TO nyse_user; | |
GRANT FILE ON *.* TO nyse_user; | |
GRANT SUPER ON *.* TO nyse_user; | |
FLUSH PRIVILEGES; | |
USE nyse; | |
CREATE TABLE `stock_eod` ( | |
`stockticker` varchar(10) NOT NULL DEFAULT '', | |
`tradedate` varchar(30) NOT NULL DEFAULT '', | |
`openprice` decimal(10,2) DEFAULT NULL, | |
`highprice` decimal(10,2) DEFAULT NULL, | |
`lowprice` decimal(10,2) DEFAULT NULL, | |
`closeprice` decimal(10,2) DEFAULT NULL, | |
`volume` bigint(20) DEFAULT NULL, | |
PRIMARY KEY (`stockticker`,`tradedate`) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We will be using /data as the reference directory | |
sudo mkdir -p /data | |
sudo su - root | |
cd /data | |
git clone https://github.com/dgadiraju/nyse_all.git | |
gunzip /data/nyse_all/nyse_data/ | |
for f in /data/nyse_all/nyse_data/*.txt | |
do | |
unlink stock_eod.txt | |
ln -s $f stock_eod.txt | |
mysqlimport \ | |
--host=127.0.0.1 \ | |
--user=nyse_user \ | |
--password=itversity \ | |
--fields-terminated-by=',' \ | |
--lines-terminated-by='\n' \ | |
--local \ | |
--lock-tables \ | |
--verbose \ | |
nyse stock_eod.txt | |
echo "Done: '"$f"' at $(date)" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the link to the repository - NYSE