Skip to content

Instantly share code, notes, and snippets.

@Coro365
Last active July 20, 2019 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Coro365/ea69f9b57eca61dd4a7f9252a58e9dc8 to your computer and use it in GitHub Desktop.
Save Coro365/ea69f9b57eca61dd4a7f9252a58e9dc8 to your computer and use it in GitHub Desktop.
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