I'm trying to create an array of stock tickers in Python 2.7 from a txt file. The txt file simply has 1 ticker per line like:
SRCE
ABTX
AMBC
ATAX
The code I'm using looks like:
FinTick= []
def parseRus():
try:
readFile=open(r'filename.txt','r').read()
splitFile=readFile.split('\n')
FinTick.append(splitFile)
print FinTick
except Exception, e:
print str(e)
When I call 'parseRus()' I get an output that looks like:
'\xff\xfeS\x00R\x00C\x00E\x00\r\x00', '\x00A\x00B\x00T\x00X\x00\r\x00', '\x00A\x00M\x00B\x00C\x00\r\x00', '\x00A\x00T\x00A\x00X\x00\r\x00'
The correct letters are present but not printing in plane text. I've used a couple other logic methods to populate the array but still get the same output format.
numpy.loadtxt. This should work better than plain opening and reading.rfrom yourr'filename.txt'open?