My goal: To convert the table in to a table that can be filtered each in retool
Issue: I 'm getting a lot more than just the table header and rows
Steps I've taken to troubleshoot:
I've connected to the URL in URL_Call and returning the data with:
const parsedString =
URL_Call.data.message.split('\n').map(function(ln){
return ln.split('\t');
});
return formatDataAsArray(parsedString)
However given the number of rows will change with each call I don't know how to grab each data cell within each row. Using and ending with for each row would work but I have no dea how.
As you can see the first table row is the headings 2-18, and then each 16 cells between the and would contain the next 16 cells of data for the next row.
Thanks very much for your help. I ended up converting it slightly differently putting it in to a JSON format using:
// Parse the HTML
const parser = new DOMParser();
const doc = parser.parseFromString(URL_Call.data.message, 'text/html');
// Select the first table
const table = doc.querySelector('table');
if (!table) return ; // Return empty array if no table is found
// Get rows
const rows = Array.from(table.querySelectorAll('tr'));
// Get header cells from the first row
const headers = Array.from(rows[0].querySelectorAll('th, td')).map(cell => cell.textContent.trim());