Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
HTML tables to csv
// selects all table rows element in an HTML document ("tr").
// for each row, select each table data element ("td").
(row) => Array.from(
// for each data element return the inner text surrounded by quotes and stripped of line breaks.
(cell) => "'" + cell.innerText.replace("\n", " ") + "'"
// join same row elements with ","
).join(", ")
// join all rows with "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment