Last active
February 16, 2022 18:36
-
-
Save neurojojo/986e1f14f1411924221dce3e21c1f0b1 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
import re, pandas as pd | |
from dateutil import parser | |
lines = []; | |
with open('ssr.csv','r') as f: | |
while 1: | |
myline = f.readline() | |
if re.search('[A-Z]+,',myline) is not None: # A line containing stock information | |
lines.append( [re.search('[A-Z]+',myline).group(0),\ | |
parser.parse( re.search('[0-9]{1,2}/[0-9]{1,2}/[0-9]+ [0-9]{1,2}:[0-9]{2}:[0-9]{2}\s[A-P]M',myline).group(0) ) ] ) | |
if len(myline)==0: | |
break # END while loop | |
ssr_database = pd.DataFrame( lines, columns=['Ticker','Datetime'] ) | |
ssr_database = ssr_database.astype({'Ticker':'string'}) | |
# Only include tickers with four characters or less | |
ssr_database = ssr_database[ ssr_database.Ticker.apply(len)<5 ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment