Last active
May 15, 2021 07:10
-
-
Save mutsune/a6d62f7d2fc97cb02f6fd06b45c33031 to your computer and use it in GitHub Desktop.
Extract albums containing songs that have been played more than 5 times
This file contains 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
from itertools import groupby | |
f = open("music.utf8.tsv") | |
lines = [l[:-1] for l in f] | |
data = [l.split("\t") for l in lines[1:]] | |
data = filter(lambda d: "Apple Music" in d[1], data) | |
data = filter(lambda d: d[2] != "", data) | |
for k, v in groupby(data, lambda c: c[0]): | |
album = list(v) | |
popular = False | |
for song in album: | |
if int(song[2]) >= 5: | |
popular = True | |
print(song) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use
nkf -d -w Music.txt | cut -d$'\t' -f4,23,26 > music.utf8.tsv
python3 fav_albums.py
python3 fav_albums.py | wc -l