Search code examples
pythonscrapyfinancestocks

Merging stock symbols with their EPS rating


I am currently using scrapy to pull the 52 week highs list off of barcharts.org. I then take that data, remove all the extra stuff, and then save it to a txt file. I then take the txt file and use it to pull EPS rating data off of investors.com website. With that I clean it up and save it to another txt file.

Now I have two txt files and want to merge them for further analysis. The way I was looking to merge it was to have two columns. The first have the contents of text file one and the second having the content of text file two.

Ive looked into maybe pulling symbols off of investors.com along with my eps rating data, but their website doesnt seem to be structured in a way to make that easy.

Any help would be appreciated.


Solution

  • Do you need something like this?

    f1=open('first.txt','r')
    f2=open('second.txt', 'r')
    new_file=open("new_text.txt", 'w')
    for line in f1:
        new_line=line +"...." + f2.readline()
        new_file.write(new_line,"\n")