Skip to content

Instantly share code, notes, and snippets.

@peio
Created October 30, 2023 07:30
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 peio/c805949aab6bd7ab3670ce87a0500972 to your computer and use it in GitHub Desktop.
Save peio/c805949aab6bd7ab3670ce87a0500972 to your computer and use it in GitHub Desktop.
Google Sheets import and cleaning of results of the 2023 Municipal election from the webiste of CIK.bg
=QUERY({
INDEX(IMPORTHTML("https://results.cik.bg/mi2023/tur1/rezultati/2246.html", "table", 1), , 1),
INDEX(IMPORTHTML("https://results.cik.bg/mi2023/tur1/rezultati/2246.html", "table", 1), , 2),
ARRAYFORMULA(IFERROR(VALUE(SUBSTITUTE(SUBSTITUTE(TRIM(INDEX(IMPORTHTML("https://results.cik.bg/mi2023/tur1/rezultati/2246.html", "table", 1), , 3)), "*", ""), " ", "")), INDEX(IMPORTHTML("https://results.cik.bg/mi2023/tur1/rezultati/2246.html", "table", 1), , 3))),
ARRAYFORMULA(IFERROR(VALUE(SUBSTITUTE(SUBSTITUTE(TRIM(INDEX(IMPORTHTML("https://results.cik.bg/mi2023/tur1/rezultati/2246.html", "table", 1), , 4)), "*", ""), " ", "")), INDEX(IMPORTHTML("https://results.cik.bg/mi2023/tur1/rezultati/2246.html", "table", 1), , 4)))
}, "SELECT * WHERE Col1 IS NOT NULL", 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment