Skip to content

Instantly share code, notes, and snippets.

@pmallory
Created February 8, 2012 20:03
Show Gist options
  • Save pmallory/1772885 to your computer and use it in GitHub Desktop.
Save pmallory/1772885 to your computer and use it in GitHub Desktop.
Music Histogram
from Foundation import *
from ScriptingBridge import *
iTunes = SBApplication.applicationWithBundleIdentifier_(
"com.apple.iTunes")
years = {}
for track in iTunes.currentPlaylist().tracks():
if not track.year() in years:
years[track.year()] = 1
else:
years[track.year()] += 1
f = open('./out.csv', 'w')
for key in sorted(years.keys()):
f.write(str(key)+', '+str(years[key]) +'\n')
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment