Skip

There's got to be a better way to do this.
May 7, 2014 8:26 AM   Subscribe

What's a good program for creating pseudo-random lists based on a master list?

I have several lists of stuff that I need to rotate through and keep track of how long its been since I've done each thing. For example: I teach weekly music classes at preschools, and every week I do 10 songs. I've got a list of lots (say 100+) of kids songs. Right now I keep track of everything in a spreed sheet and include the date of the last time I sang a song, and then create a list of the 10 songs I'm going to do by hand.

I'd like a program that could generate a list of 10 songs (or X whatevers) from the master list and be able to add weight to different factors: how long it's been since I've done the song, how the much the kids like the song, maybe even add tags (like say songs about frogs) and stick songs with the same tag together. Basically like the Itunes shuffle function, but for other things.

Does such a thing exist? If so what is it called, and do you have an recommendations?

If it matters, I've got access to a mac, a pc, and a kindle fire, but would prefer to do this on either the mac or the kindle.
posted by Gygesringtone to Computers & Internet (4 answers total) 3 users marked this as a favorite
 
I don't think doing this for a single weighting criterion would be too hard. My naive approach would be to create a list of all your songs, where each song has a number of entries in the list equal to the number of days since it was last performed. That could easily be done with a few lines of your scripting language of choice, or I'd imagine even in a spreadsheet if you knew the magic. (I'm not a spreadsheet wizard).

Making it N-dimensional would be a little bit difficult. You'd have to decide how to balance the weight factors between your criteria. How many days of time is a kid liking it worth, for example?

I don't know of any canned tools to do this; someone else here might. If not, it would be easy to whip up a python script which would take care of at least the simple case. You could run that on your Mac.
posted by jammer at 8:42 AM on May 7


I've gone ahead and written a very simple python script which will take a CSV containing song data and spit out a choice biased by the number of days since a song was last played. Assume an input file like this:
song_name,last_played
song1,2014-02-01
song2,2014-03-01
song3,2014-04-01
Put this script into a file:
#!/bin/env python

import sys
import csv
import random
import datetime

songlist = []
today = datetime.datetime.today()

infile = open(sys.argv[1])
reader = csv.DictReader(infile)

for line in reader:
    last_played = datetime.datetime.strptime(line['last_played'], '%Y-%m-%d')
    songlist.extend([line['song_name']] * (today - last_played).days)

print random.choice(songlist)
And then run it on your command line with the name of the CSV as an argument. eg:

python chooser.py songs.csv

It will print out the name of one song picked from the list for you.

(This is not an example of bullet-proof python code, nor the most efficient algorithm for this, but it gets the job done, and I didn't want it to be too impenetrable to you if you want to understand what's going on.)

If this is the route you choose to go and you need more guidance on how to do this on your Mac, we can help.
posted by jammer at 10:37 AM on May 7 [3 favorites]


(A more efficient way of doing this, especially with large data sets or if you begin adding more dimensions of weight, would be to calculate a ratio amongst all entries, map that to a range of numbers, such as from 0 to 1, then generate a random number within that range and determine which entry it relates to based upon the defined ratios.)
posted by jammer at 11:35 AM on May 7


Add a column to the spreadsheet and fill it with random numbers, then sort by that column. you may have to fill the column with a random number function, then Cut, Paste Values. (I don't use Excel often.)
posted by SemiSalt at 1:19 PM on May 7


« Older Oh, kind people of Metafilter....   |  I am planning an event that I ... Newer »

You are not logged in, either login or create an account to post comments



Post