I want to convert my Yahoo Earnings Calendar page scraper that creates a csv file to a GUI but I noticed if there were too many companies being reported that day, the tkinter window was only so big to display a set amount. I was wondering if there was a way to implement a scrollbar to my window. Any help is appreciated thanks!
from tkinter import *
from tkinter.tix import *
import csv
from datetime import date
import yahooFinanceToCSV
root = Tk()
# open file
with open(r'earnings_{}.csv'.format(date.today()), newline = "") as file:
reader = csv.reader(file)
# r and c tell us where to grid the labels
r = 0
for col in reader:
c = 0
for row in col:
# i've added some styling
label = tkinter.Label(root, width = 35, height = 2, \
text = row, relief = tkinter.RIDGE)
label.grid(row = r, column = c)
c += 1
r += 1
root.mainloop()
My yahoo earnings scraper code
import pandas as pd
from datetime import date
# Forcing Pandas to display max rows and columns.
pd.option_context('display.max_rows', None, 'display.max_columns', None)
# Reading the earnings calendar table on yahoo finance website.
# earnings = pd.read_html('https://finance.yahoo.com/calendar/earnings')[0]
earnings = pd.read_html("https://finance.yahoo.com/calendar/earnings?from=2020-01-19&to=2020-01-25&day=2020-01-21")[0]
# Writing to a CSV file.
earnings.to_csv(r'earnings_{}.csv'.format(date.today()), index=None)
NOTE: The HTML is being forced to January 21 2020 because there 40ish companies reporting. Usually I run the code daily for said day's earnings but 21st Jan 2020 helps recreating the issue that needs to be solved.