def top_ten_albums_last_28days(): global albumcount global logcount f.write("{:<80}{:>10}{:>10}\n".format("Last 28 Days", "Plays", "Hours")) f.write("-" * 105 + "\n") sql = "select `artist`.`ArtistName` AS `ArtistName`,`album`.`Album` AS `Album`," \ "sum(`albumlengths`.`albumlength`) AS `Points`,count(`log`.`logID`) AS `Plays` " \ "from ((((`artist` join albumartist on artist.artistid = albumartist.artistid inner join `album` " \ "on((`albumartist`.`albumID` = `album`.`albumID`))) " \ "join `albumlengths` on((`album`.`AlbumID` = `albumlengths`.`albumid`))) " \ "join `log` on((`log`.`AlbumID` = `album`.`AlbumID`))) " \ "join `albumtype` on((`album`.`AlbumTypeID` = `albumtype`.`AlbumTypeID`))) " \ "where log.logDate > (DATE_SUB(CURRENT_DATE, INTERVAL 28 DAY)) and album.albumtypeid<>16 " \ "group by `artist`.`ArtistID`,`album`.`AlbumID`,`artist`.`ArtistName`,`album`.`Album` " \ "order by sum(`albumlengths`.`albumlength`) desc limit 10" results = common.get_results(sql) for r in results: artistname = common.shorten_by_word(r[0], 35) title = common.shorten_by_word(r[1], 35) playcount = int(r[3]) playedtime = r[2] / 3600 line = "{:<40}{:<40}{:>10}{:>10.2f}\n".format(artistname.upper(), title, playcount, playedtime) f.write(line) f.write("\n\n")
def main(): openreportfile() f.write("COLLECTION AS OF {}\n\n".format(date.today().strftime("%Y-%m-%d"))) sql = "SELECT * from albumlist where AlbumType<>'Deleted';" c = conn.cursor() c.execute(sql) rows = c.fetchall() currentartist = "" currenttype = "" creditslist = [None] for r in rows: mbid, sortname, isgroup, artistid, artist, albumtype, yearreleased, album, label, source, \ albumlength, playcount, lastplayed, discs, tracks, bonus, artistcredit, rank, albumid = r[:19] atr = all_time_rank(albumid) album = common.shorten_by_word(album, 75) label = common.shorten_by_word(label, 25) if mbid != currentartist: if len(creditslist) > 1: add_credits(creditslist) creditslist = [None] f.write("=" * 180 + "\n\n\n") f.write("=" * 180 + "\n") f.write(artist.upper() + "\n") add_relationships(artistid, isgroup) currenttype = "" f.write("-" * 180+ "\n") add_header() #f.write("-" * 155+ "\n") if (albumtype != currenttype): f.write("-" * 180 + "\n") if artistcredit != artist: if artistcredit not in creditslist: creditslist.append(artistcredit) creditindex = creditslist.index(artistcredit) album += " ({})".format(creditindex) linestr = "{:<20}{:<10}{:<2}{:<80}{:<25}{:>10}{:>5}{:>5}{:>5}{:>5}{:>5}{:>5}\n".format("" if currenttype == albumtype else albumtype, yearreleased, "*" if playcount > 0 else " ", album, source, common.format_to_MS(albumlength), playcount, discs, tracks, bonus, "-" if rank is None else rank, "-" if atr is None else atr) f.write(linestr) currentartist = mbid currenttype = albumtype if len(creditslist) > 1: add_credits(creditslist)
def albums_played_multi_times_in_single_day(): sql = "select distinct artistcredit, album from multiple_plays_per_day;" results = common.get_results(sql) last_log_date = None for r in results: artistname = common.shorten_by_word(r[0], 35) album = common.shorten_by_word(r[1], 35) line = "{:<40}{:<40}\n".format(artistname.upper(), album) f.write(line) f.write("\n\n")
def top_ten_artists_log(): global albumcount global logcount f.write("{:<30}{:>10}{:>11}{:>10}{:>11}{:>10}{:>11}{:>10}\n".format( "by Plays", "Count", "%", "Plays", "%", "Played", "%", "Ratio")) f.write("-" * 105 + "\n") sql = "select artist.ArtistName, count(album.AlbumID) as Albums, sum(album.PlayCount) as Plays, sum(album.played) as Played " \ "from artist inner join albumartist on artist.artistid = albumartist.artistid " \ "inner join album on album.albumid = albumartist.albumid " \ "where album.albumtypeid<>16 group by artist.ArtistName order by Plays desc limit 10;" results = common.get_results(sql) for r in results: artistname = common.shorten_by_word(r[0], 25) count = int(r[1]) percent = 0 if albumcount == 0 else (count / albumcount) * 100 playcount = int(r[2]) logpercent = 0 if logcount == 0 else (playcount / logcount) * 100 played = int(r[3]) playedpercent = 0 if count == 0 else (played / count) * 100 ratio = 0 if played == 0 else playcount / played line = "{:<30}{:>10}{:>10.2f}%{:>10}{:>10.2f}%{:>10}{:>10.2f}%{:>10.2f}\n".format( artistname.upper(), count, percent, playcount, logpercent, played, playedpercent, ratio) f.write(line) f.write("\n\n")
def top_ten_artists_28days(): global albumcount global logcount f.write("{:<30}{:>10}{:>11}\n".format("Last 28 Days", "Plays", "Hours")) f.write("-" * 80 + "\n") sql = "select artist.ArtistName, sum(albumlengths.albumlength)/3600 as hours, count(log.logID) as logged " \ "from log inner join albumlengths on log.AlbumID = albumlengths.AlbumID " \ "inner join album on album.albumid = albumlengths.albumid " \ "inner join albumartist on album.albumid = albumartist.albumid " \ "inner join artist on albumartist.artistid = artist.ArtistID " \ "where log.logDate > (DATE_SUB(CURRENT_DATE, INTERVAL 28 DAY)) and album.albumtypeid<>16 " \ "group by artist.ArtistName order by hours desc limit 10;" results = common.get_results(sql) for r in results: artistname = common.shorten_by_word(r[0], 25) count = int(r[2]) time = r[1] line = "{:<30}{:>10}{:>11.2f}\n".format(artistname.upper(), count, time) f.write(line) f.write("\n\n")
def albums_played_last_14days(): sql = "select artistcredit, album, logdate from log_history where logdate > (DATE_SUB(CURRENT_DATE, INTERVAL 14 DAY))" results = common.get_results(sql) last_log_date = None for r in results: artistname = common.shorten_by_word(r[0], 35) album = common.shorten_by_word(r[1], 35) logdate = r[2] if logdate != last_log_date: f.write("\n" + ("-" * 5) + " " + str(logdate) + " " + ("-" * 88) + "\n\n") last_log_date = logdate line = "{:<40}{:<40}\n".format(artistname.upper(), album) f.write(line) f.write("\n\n")
def albums_added_last_14days(): sql = "select artistcredit, album, datepurchased, source from recent_additions where source <> 'Digital' and " \ "datepurchased > (DATE_SUB(CURRENT_DATE, INTERVAL 28 DAY))" results = common.get_results(sql) last_log_date = None for r in results: artistname = common.shorten_by_word(r[0], 35) album = common.shorten_by_word(r[1], 35) datepurchased = r[2] source = r[3] if datepurchased != last_log_date: f.write("\n" + ("-" * 5) + " " + str(datepurchased) + " " + ("-" * 88) + "\n\n") last_log_date = datepurchased line = "{:<40}{:<40}{:<10}\n".format(artistname.upper(), album, source) f.write(line) f.write("\n\n")
def run(): for yr in range(2018, date.today().year + 1): for qtr in range(1, 5): sql = "SELECT artist.artistid, artist.artistname as Artist, count(log.logid) as Plays, sum(albumlengths.albumlength) as Time, Totals.TotalPlays as TotalPlays, Totals.TotalTime " sql += "FROM log INNER JOIN albumlengths on log.albumid = albumlengths.albumid " sql += "INNER JOIN albumartist on albumlengths.albumid = albumartist.albumid " sql += "INNER JOIN artist on artist.artistid = albumartist.artistid " sql += "INNER JOIN albumview as album on album.albumid = albumartist.albumid " sql += "JOIN (SELECT COUNT(log.logid) as TotalPlays, SUM(albumlengths.albumlength) as TotalTime FROM log inner join albumlengths on log.albumid = albumlengths.albumid) Totals " sql += "WHERE YEAR(log.logdate) = " + str( yr) + " and MONTH(log.logdate) IN (" + monthstring[ qtr] + ") and album.albumtypeid <> 16 GROUP BY Artist;" chart = pd.read_sql(sql, common.conn) chart['TimeScore'] = (chart['Time'] / chart['TotalTime']) * 100 chart['FreqScore'] = (chart['Plays'] / chart['TotalPlays']) * 100 chart['WeightedScore'] = (chart['TimeScore'] * 0.5) + (chart['FreqScore'] * 0.5) chart.sort_values('WeightedScore', ascending=False, inplace=True) chart['Rank'] = chart['WeightedScore'].rank(ascending=False) chart_formatted = chart[[ 'Rank', 'artistid', 'Artist', 'TimeScore', 'FreqScore', 'WeightedScore' ]][:30] chart_array = chart_formatted.values.tolist() base_filename = "Artist Chart - {} Q{}.txt".format(yr, qtr) if len(chart_array) > 1: basedir = os.path.join(common.basedir, 'Seasonal', 'Artist') if not os.path.exists(basedir): os.mkdir(basedir) with open(os.path.join(basedir, base_filename), 'w', encoding='utf-8') as outfile: header = "{:<5}{:<80}{:>10}{:>10}{:>10}\n".format( "RANK", "", "TIME", "FREQ", "TOTAL") outfile.write(seperator + header + seperator) for a in chart_array: rank, artistid, artist, timescore, freqscore, weightedscore = a common.add_chart_history(yr, qtr, artistid, 0, rank, weightedscore, 0) textline = "{:<5}{:<80}{:>10.2f}{:>10.2f}{:>10.2f}\n".format( int(rank), common.shorten_by_word(artist.upper(), 80), timescore, freqscore, weightedscore) outfile.write(textline) outfile.write(seperator)
def albums_requiring_rerip(): global albumcount global logcount f.write("{:<80}{:>10}\n".format("Requiring Re-Rip/Re-Import", "Plays")) f.write("-" * 105 + "\n") sql = "select artistcredit, album, playcount FROM albumview as album where TBA=1 " \ "order by playcount desc, artistcredit, album; " results = common.get_results(sql) for r in results: artistname = common.shorten_by_word(r[0], 35) title = common.shorten_by_word(r[1], 35) playcount = int(r[2]) line = "{:<40}{:<40}{:>10}\n".format(artistname.upper(), title, playcount) f.write(line) f.write("\n\n")
def albums_requiring_purchase(): global albumcount global logcount f.write("{:<80}{:>10}\n".format("Requiring Purchase", "Plays")) f.write("-" * 105 + "\n") sql = "select artistname, title, count(*) as Plays from log_reimport lr where lr.input is null and lr.requires_rerip is null " \ "group by artistname, title having Plays >= 3 order by plays desc, artistname, title LIMIT 10" results = common.get_results(sql) for r in results: artistname = common.shorten_by_word(r[0], 35) title = common.shorten_by_word(r[1], 35) playcount = int(r[2]) line = "{:<40}{:<40}{:>10}\n".format(artistname.upper(), title, playcount) f.write(line) f.write("\n\n")
def top_ten_streams_bycount(): global albumcount global logcount f.write("{:<80}{:>10}{:>10}\n".format("Streams", "Plays", "Hours")) f.write("-" * 105 + "\n") sql = "select artistname, album, Plays, Points from chart_streamed_alltime order by Plays desc LIMIT 10" results = common.get_results(sql) for r in results: artistname = common.shorten_by_word(r[0], 35) title = common.shorten_by_word(r[1], 35) playcount = int(r[2]) playedtime = r[3] / 3600 line = "{:<40}{:<40}{:>10}{:>10.2f}\n".format(artistname.upper(), title, playcount, playedtime) f.write(line) f.write("\n\n")
def run(): for yr in range(2018, date.today().year + 1): sql = "SELECT album.artistcredit as Artist, album.albumid as albumid, albumlengths.album as Album, count(log.logid) as Plays, sum(albumlengths.albumlength) as Time, Totals.TotalPlays, Totals.TotalTime " sql += "FROM log INNER JOIN albumlengths on log.albumid = albumlengths.albumid " sql += "INNER JOIN albumview as album on albumlengths.albumid = album.albumid " sql += "JOIN (SELECT YEAR(log.logdate) as Y, COUNT(log.logid) as TotalPlays, SUM(albumlengths.albumlength) as TotalTime FROM log inner join albumlengths on log.albumid = albumlengths.albumid) Totals " sql += "WHERE album.yearreleased = " + str( yr) + " and album.albumtypeid <> 16 GROUP BY Artist, Album;" chart = pd.read_sql(sql, common.conn) chart['TimeScore'] = (chart['Time'] / chart['TotalTime']) * 100 chart['FreqScore'] = (chart['Plays'] / chart['TotalPlays']) * 100 chart['WeightedScore'] = (chart['TimeScore'] * 0.5) + (chart['FreqScore'] * 0.5) chart.sort_values('WeightedScore', ascending=False, inplace=True) chart['Rank'] = chart['WeightedScore'].rank(ascending=False) chart_formatted = chart[[ 'Rank', 'albumid', 'Artist', 'Album', 'TimeScore', 'FreqScore', 'WeightedScore' ]][:50] chart_array = chart_formatted.values.tolist() base_filename = "Album Chart (This Year's Releases) - {}.txt".format( yr) full_dir = os.path.join(common.basedir, 'Annual', str(yr)) if not os.path.exists(full_dir): os.makedirs(full_dir) with open(os.path.join(full_dir, base_filename), 'w', encoding='utf-8') as outfile: header = "{:<5}{:<80}{:>10}{:>10}{:>10}\n".format( "RANK", "", "TIME", "FREQ", "TOTAL") outfile.write(seperator + header + seperator) for a in chart_array: rank, albumid, artist, album, timescore, freqscore, weightedscore = a textline = "{:<5}{:<80}{:>10.2f}{:>10.2f}{:>10.2f}\n".format( int(rank), common.shorten_by_word(artist.upper() + ": " + album, 80), timescore, freqscore, weightedscore) common.add_chart_history(yr, 0, 0, albumid, rank, weightedscore, 1) outfile.write(textline) outfile.write(seperator)
def run(): for source in ['Vinyl', 'CD', 'Cassette', 'Cassette (Dubbed)', 'Digital']: sql = "SELECT album.artistcredit as Artist, albumlengths.album as Album, source.source, count(log.logid) as Plays, sum(albumlengths.albumlength) as Time, Totals.TotalPlays, Totals.TotalTime " sql += "FROM log INNER JOIN albumlengths on log.albumid = albumlengths.albumid " sql += "INNER JOIN album on albumlengths.albumid = album.albumid " \ "INNER JOIN source on album.sourceid = source.sourceid " sql += "JOIN (SELECT COUNT(log.logid) as TotalPlays, SUM(albumlengths.albumlength) as TotalTime FROM log inner join albumlengths on log.albumid = albumlengths.albumid) Totals " sql += "WHERE album.albumtypeid <> 16 and log.logdate >= '2017-01-01' and source = '{}' GROUP BY Artist, Album, source;".format( source) chart = pd.read_sql(sql, common.conn) chart['TimeScore'] = (chart['Time'] / chart['TotalTime']) * 100 chart['FreqScore'] = (chart['Plays'] / chart['TotalPlays']) * 100 chart['WeightedScore'] = ((chart['TimeScore'] * 0.5) + (chart['FreqScore'] * 0.5)) chart.sort_values('WeightedScore', ascending=False, inplace=True) chart['Rank'] = chart['WeightedScore'].rank(ascending=False) chart_formatted = chart[[ 'Rank', 'Artist', 'Album', 'TimeScore', 'FreqScore', 'WeightedScore' ]][:25] chart_array = chart_formatted.values.tolist() base_filename = "Album Chart - {}.txt".format(source) full_dir = os.path.join(common.basedir, 'By Format') if not os.path.exists(full_dir): os.makedirs(full_dir) with open(os.path.join(full_dir, base_filename), 'w', encoding='utf-8') as outfile: header = "{:<5}{:<80}{:>10}{:>10}{:>10}\n".format( "RANK", "", "TIME", "FREQ", "TOTAL") outfile.write(seperator + header + seperator) for a in chart_array: rank, artist, album, timescore, freqscore, weightedscore = a textline = "{:<5}{:<80}{:>10.2f}{:>10.2f}{:>10.2f}\n".format( int(rank), common.shorten_by_word(artist.upper() + ": " + album, 80), timescore, freqscore, weightedscore) outfile.write(textline) outfile.write(seperator)
def top_ten_artists_time_played(): global albumcount global logcount f.write("{:<31}{:>9}{:>11}\n".format("by Time Played", "Plays", "Hours")) f.write("-" * 80 + "\n") sql = "select artistname, plays, points / 3600 as hours from chart_artist_alltime order by hours desc limit 10;" results = common.get_results(sql) for r in results: artistname = common.shorten_by_word(r[0], 25) count = int(r[1]) time = r[2] line = "{:<30}{:>10}{:>11.2f}\n".format(artistname.upper(), count, time) f.write(line) f.write("\n\n")
def generate_chart(outfile, data, basedir, y): totalplays = int(get_total_plays(y)) totaltime = int(get_total_time(y)) if len(data) > 0: f = io.open(os.path.join(basedir, outfile), "w", encoding='utf-8') header = "{:<5}{:<80}{:>10}{:>10}{:>10}\n".format( "RANK", "", "TIME", "FREQ", "TOTAL") f.write(seperator) f.write(header) f.write(seperator) datadict = [] rank = 1 for dataline in data: art = dataline[0][:40] album = dataline[1] logtime = int(dataline[2]) logcount = int(dataline[3]) albumid = int(dataline[4]) timeshare = (logtime / totaltime) * 100 freqshare = (logcount / totalplays) * 100 weighted_score = ((timeshare * 0.5) + (freqshare * 0.5)) datadict_line = [ art, album, albumid, timeshare, freqshare, weighted_score ] datadict.append(datadict_line) s = sorted(datadict, key=lambda x: x[5], reverse=True) for row in s: art, album, albumid, timeshare, freqshare, score = row[:6] textline = "{:<5}{:<80}{:>10.2f}{:>10.2f}{:>10.2f}\n".format( rank, common.shorten_by_word(art.upper() + " / " + album, 80), timeshare, freqshare, score) f.write(textline) f.write(seperator) if y != 0: add_weighted_ranking(y, albumid, rank, score) rank += 1 f.flush() f.close()
def run(): sql = "SELECT artist.artistid, artist.artistname as Artist, count(log.logid) as Plays, sum(albumlengths.albumlength) as Time, Totals.TotalPlays, Totals.TotalTime " sql += "FROM log INNER JOIN albumartist ON log.albumid = albumartist.albumid " sql += "INNER JOIN albumlengths on albumartist.albumid = albumlengths.albumid " sql += "INNER JOIN albumview as album on albumlengths.albumid = album.albumid " sql += "INNER JOIN artist on albumartist.artistid = artist.artistid " sql += "JOIN (SELECT COUNT(log.logid) as TotalPlays, SUM(albumlengths.albumlength) as TotalTime FROM log inner join albumlengths on log.albumid = albumlengths.albumid) Totals " sql += "WHERE album.albumtypeid <> 16 GROUP BY Artist;" chart = pd.read_sql(sql, common.conn) chart['TimeScore'] = chart['Time'] / chart['TotalTime'] * 100 chart['FreqScore'] = chart['Plays'] / chart['TotalPlays'] * 100 chart['WeightedScore'] = (chart['TimeScore'] * 0.5) + (chart['FreqScore'] * 0.5) chart.sort_values('WeightedScore', ascending=False, inplace=True) chart['Rank'] = chart['WeightedScore'].rank(ascending=False) chart_formatted = chart[[ 'Rank', 'artistid', 'Artist', 'TimeScore', 'FreqScore', 'WeightedScore' ]][:100] chart_array = chart_formatted.values.tolist() base_filename = "Artist Chart (All Time).txt" with open(os.path.join(common.basedir, 'All Time', base_filename), 'w', encoding='utf-8') as outfile: header = "{:<5}{:<80}{:>10}{:>10}{:>10}\n".format( "RANK", "", "TIME", "FREQ", "TOTAL") outfile.write(seperator + header + seperator) for a in chart_array: rank, artistid, artist, timescore, freqscore, weightedscore = a textline = "{:<5}{:<80}{:>10.2f}{:>10.2f}{:>10.2f}\n".format( int(rank), common.shorten_by_word(artist.upper(), 80), timescore, freqscore, weightedscore) common.add_chart_history(0, 0, artistid, 0, rank, weightedscore, 0) outfile.write(textline) outfile.write(seperator)
def top_ten_artists_time_total(): global albumcount global logcount f.write("{:<30}{:>10}{:>11}\n".format("by Time Total", "Count", "Hours")) f.write("-" * 80 + "\n") sql = "select artistname, count(album.albumid) as albums, sum(albumlength) / 3600 as hours from " \ "albumlengths inner join album on albumlengths.albumid = album.albumid " \ "inner join albumartist on album.albumid = albumartist.albumid " \ "inner join artist on albumartist.artistid = artist.artistid " \ "where album.albumtypeid<>16 " \ "group by artistname order by hours desc limit 10;" results = common.get_results(sql) for r in results: artistname = common.shorten_by_word(r[0], 25) count = int(r[1]) time = r[2] line = "{:<30}{:>10}{:>11.2f}\n".format(artistname.upper(), count, time) f.write(line) f.write("\n\n")
def generate(chart_date=None): if chart_date is None: last_sunday = date.today() - timedelta(days=date.today().weekday() + 1) else: if chart_date.weekday() != 6: last_sunday = chart_date - timedelta(days=chart_date.weekday() + 1) else: last_sunday = chart_date date_range = last_sunday - timedelta(weeks=13) + timedelta(days=1) sql = "SELECT artist.artistid, artist.artistname as Artist, count(log.logid) as Plays, sum(albumlengths.albumlength) as Time, Totals.TotalPlays, Totals.TotalTime " sql += "FROM log INNER JOIN albumartist ON log.albumid = albumartist.albumid " sql += "INNER JOIN albumlengths on albumartist.albumid = albumlengths.albumid " sql += "INNER JOIN albumview as album on albumlengths.albumid = album.albumid " sql += "INNER JOIN artist on albumartist.artistid = artist.artistid " sql += "JOIN (SELECT COUNT(log.logid) as TotalPlays, SUM(albumlengths.albumlength) as TotalTime FROM log inner join albumlengths on log.albumid = albumlengths.albumid) Totals " sql += "WHERE log.logdate BETWEEN '{}' AND '{}' and album.albumtypeid <> 16 GROUP BY Artist;".format( date_range.strftime("%Y-%m-%d"), last_sunday.strftime("%Y-%m-%d")) chart = pd.read_sql(sql, common.conn) chart['TimeScore'] = (chart['Time'] / chart['TotalTime']) * 100 chart['FreqScore'] = (chart['Plays'] / chart['TotalPlays']) * 100 chart['WeightedScore'] = (chart['TimeScore'] * 0.5) + (chart['FreqScore'] * 0.5) chart.sort_values('WeightedScore', ascending=False, inplace=True) chart['Rank'] = chart['WeightedScore'].rank(ascending=False) chart_formatted = chart[['Rank', 'artistid', 'Artist', 'TimeScore', 'FreqScore', 'WeightedScore']][:40] chart_array = chart_formatted.values.tolist() base_filename = "Artist Chart (Rolling) - {}.txt".format(last_sunday.strftime("%Y-%m-%d")) full_dir = os.path.join(common.basedir, 'Rolling', 'Artist') common.execute_sql("DELETE FROM chart_history_rolling WHERE chartdate='{}' AND artistid <> 0;".format(last_sunday.strftime("%Y-%m-%d"))) if not os.path.exists(full_dir): os.makedirs(full_dir) with open(os.path.join(full_dir, base_filename), 'w', encoding='utf-8') as outfile: header = "{:<5}{:<5}{:<80}{:>10}{:>10}{:>10}\n".format("RANK", "+/-", "", "TIME", "FREQ", "TOTAL") outfile.write(seperator + header + seperator) for a in chart_array: rank, artistid, artist, timescore, freqscore, weightedscore = a lw_rank = get_last_rank(artistid, last_sunday) lw_string="" chartrun = get_last_run(artistid) if lw_rank is None: if chartrun == 0: lw_string = "N" chartrun = 1 else: lw_string = "R" chartrun += 1 else: if int(rank) < lw_rank: lw_string = "+" else: lw_string = "" textline = "{:<5}{:<5}{:<80}{:>10.2f}{:>10.2f}{:>10.2f}\n".format(int(rank), lw_string, common.shorten_by_word(artist.upper(), 80), timescore, freqscore, weightedscore) common.add_rolling_chart_history(last_sunday.strftime("%Y-%m-%d"), artistid, 0, rank, weightedscore, chartrun) outfile.write(textline) outfile.write(seperator)