comment_filename = 'comments_data.txt'  # where to save the treated comments
load_backup = True  # Using the file with the saved comments
normalized_rep = 1000  # Score normalization

## general
normalized_rep = 1000.
team = ['null']
bots = []
blacklist = []

# Welcome message
print("Start of the run on:", time.asctime(time.localtime(time.time())), '\n')

# Get all steemstem votes
s = Steem()
all_votes = s.get_account_votes("steemstem")


# Method to get each post reputation value, and adding it to the associated author
def get_scores(excluded=[]):
    author_scores = {}
    comment_scores = {}
    comment_backup = {}

    # saving a comment score
    def save(dico, author, val):
        if not author in excluded:
            if not author in dico.keys():
                dico[author] = [val, 1]
            else:
                dico[author] = [dico[author][0] + val, dico[author][1] + 1]
witnessDf=pd.DataFrame(s.get_witnesses_by_vote('',30))
witnesses = witnessDf['owner'].tolist()
print(s.get_account('jaredcwillis')['sbd_balance'])
print(witnesses)
selfVoteslist=[]
totalVoteslist=[]
#####
#Pulls voting lists for active witnesses
####

for currentWitness in witnesses:
    print(currentWitness)
#####
#Count number of total votes and make sure it isn't 0
####
    print(len(s.get_account_votes(currentWitness)))
    if len(s.get_account_votes(currentWitness)) > 0:
        totalVoteslist.append(len(s.get_account_votes(currentWitness)))
#####
#Convert voting activity to csv file, 
#splitting individual post URLs into author name and title
####
        tempDf=pd.DataFrame(s.get_account_votes(currentWitness))
        tempDf["authorName"], tempDf["postName"] = zip(*tempDf["authorperm"].str.split(pat="/").tolist())
        del tempDf["authorperm"]
        tempDf.to_csv("votes_%s.csv" % currentWitness)
#####
#Count number of self votes
####
        numberSelfvotes=tempDf.authorName.value_counts()[currentWitness]
        print(numberSelfvotes)