Last active
September 10, 2016 17:32
-
-
Save wesdoyle/fa41fa9fa4ed966b6e2b3cb66b4124df to your computer and use it in GitHub Desktop.
Method to plot year histogram from iTunes playlist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plotYearHisto(fileName): | |
""" | |
Plot year histogram using XML playlist from iTunes. | |
""" | |
plist = plistlib.readPlist(fileName) | |
tracks = plist['Tracks'] | |
years = [] | |
for trackId, track in tracks.items(): | |
try: | |
years.append(track['Year']) | |
except: | |
pass | |
if years == []: | |
print("Playlist file does not contain valid track year data.") | |
return | |
x = np.array(years) | |
plt.plot() | |
plt.hist(x, bins=20, color='midnightblue') | |
plt.title('Song Year Histogram for %s' % fileName) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment