Skip to content

Instantly share code, notes, and snippets.

@alanstevens
Last active July 20, 2017 23:13
Show Gist options
  • Save alanstevens/946198fee25a01f41c2eeb8aaf709ed6 to your computer and use it in GitHub Desktop.
Save alanstevens/946198fee25a01f41c2eeb8aaf709ed6 to your computer and use it in GitHub Desktop.
Gather song list by decade
  1. Get results for each year from:
  1. Put results in vim and clean up
  2. remove the chart rank in vim with: :%s/^\d* //
  3. manually add a hyphen between track and artist
  4. reverse track name and artist for tunecaster results using script below
  5. concatenate year lists
  6. order by artist, then track name for all year results and remove any exact match duplicates using script below
  7. prefix lines with the year and a hyphen using vim (ctrl v)
  8. merge all year lists into one decade list
  9. run script below to sort decade list
  10. manually remove any remaining duplicates selecting the earliest year
  11. normalize artist names e.g.: Rolling Stones vs. The Rolling Stones
  12. create a gather list using the script below
#!/Users/Alan/.rbenv/shims/ruby -w
output = ""
artists ||= []
tracks ||= []
File.open( File.expand_path(File.dirname(__FILE__), 'all.txt' ) ).each do |line|
tracks << line
artist = line.split(" - ")[1]
artists << artist
end
records = Hash.new(0)
artists.each do |value|
records[value] += 1
end
sortedRecords = records.sort_by { |artistname, count| count }
artisttracks ||= []
sortedRecords.reverse.each do |artistname, count|
header = "#{count} - #{artistname}"
puts header
output +="#{header}\n"
artisttracks = tracks.select { |a| a.split(" - ")[1] == artistname }
artisttracks.each do |track|
tracktext = " #{track}"
puts tracktext
output += tracktext
end
end
File.open("output.txt", 'w') { |file| file.write(output) }
#!/Users/Alan/.rbenv/shims/ruby -w
Item = Struct.new(:artist, :track)
tracks = []
ARGF.each_line do |line|
split = line.split(" - ")
next if split[1].nil?
tracks.push(Item.new(split[0], split[1].strip))
end
sorted = tracks.sort_by{|e| [e.artist, e.track]}
unique = sorted.uniq{|e| [e.artist, e.track]}
unique.each do |item|
puts item.artist + " - " + item.track
end
#!/Users/Alan/.rbenv/shims/ruby -w
output = ""
Item = Struct.new(:year, :artist, :track)
tracks = []
ARGF.each_line do |line|
split = line.split(" - ")
next if split[1].nil?
tracks.push(Item.new(split[0].strip, split[1].strip, split[2].strip))
end
sorted = tracks.sort_by{|e| [e.artist, e.track]}
sorted.each do |item|
output += item.year + " - " + item.artist + " - " + item.track + "\n"
end
puts output
# File.open( File.expand_path(File.dirname(__FILE__), 'all.txt' ) ).each do |line|
File.open("sorted_decade.txt", 'w') { |file| file.write(output) }
#!/Users/Alan/.rbenv/shims/ruby -w
# Reverses artist and track name for tunecaster results
output = ""
ARGF.each_line do |line|
split = line.split(" - ")
begin
new_line = split[1].strip + " - " + split[0]
output += "#{new_line}\n"
rescue
end
end
puts output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment