Skip to content

Instantly share code, notes, and snippets.

@dgadiraju
Last active February 19, 2023 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save dgadiraju/ce1ccf641911c5d6cb414a0b06b93a06 to your computer and use it in GitHub Desktop.
Save dgadiraju/ce1ccf641911c5d6cb414a0b06b93a06 to your computer and use it in GitHub Desktop.
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`)
);
# 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
@dgadiraju
Copy link
Author

Here is the link to the repository - NYSE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment