Skip to content

Instantly share code, notes, and snippets.

@mulderp
Created December 4, 2013 22:17
Show Gist options
  • Save mulderp/7796615 to your computer and use it in GitHub Desktop.
Save mulderp/7796615 to your computer and use it in GitHub Desktop.
a small converter for a dataset from http://www.grouplens.org/datasets/movielens/)
f = File.new("u.item_utf8")
ls = f.readlines
puts "["
ls.each do |l|
fs = l.split("|")
/(.*) \((\d+)\)$/.match(fs[1])
title = $1
year = $2
url = fs[4]
puts %Q{{"title": "#{title}", "year": #{year ? year : 0}, "url": "#{url}"}, }
end
puts "]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment