FindingMusic/sources/find-duplicates-2.lua
2021-03-02 02:14:24 -07:00

23 lines
525 B
Lua
Executable File

#!/usr/bin/env lua
local cjson = require("cjson")
local music = io.open("music-cleaned.csv", "r")
local unique_tracks = {}
for track in music:lines() do
local normalized_track = track:gsub("%W", ""):lower()
if unique_tracks[normalized_track] then
table.insert(unique_tracks[normalized_track].names, track)
else
unique_tracks[normalized_track] = { names = { track } }
end
end
music:close()
local output_file = io.open("music.json", "w")
output_file:write(cjson.encode(unique_tracks))
output_file:close()