Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display the duplicate rows in the first column of the specified public Google Spread Sheet
# 指定したパブリックな Google Spread Sheet の1列目の値が重複した行を表示します
gss_url = "https://docs.google.com/spreadsheets/d/1iq_4d5ECOO6p5c3zJJg_mUMBNTPWbUzxGTxrNwGh8zs/htmlview?usp=sharing&sle=true"
def download_ggs(gss_url)
gss_html = `curl -# #{gss_url}`
ptt = /<div class="row-header-wrapper" style="line-height: 20px;">(\d*?)<\/div><\/th><td class.*?>(.*?)<\/td>/
ggs = gss_html.scan(ptt)
end
id_and_song = download_ggs(gss_url)
songs = id_and_song.map { |row| row[1] }
duplicate_songs = songs.select{ |e| songs.count(e) > 1 }.uniq
dupl_rows = duplicate_songs.map do |dsong|
i = id_and_song.map { |e| e if e[1] == dsong }.compact
ids = i.map { |e| e[0] }
[ids.join("/"),dsong].join(" ")
end
puts dupl_rows ? "No duplication" : dupl_rows.join(" | ")
# https://www.youtube.com/watch?v=-k-qwhtR4Qg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.