* Builds a CSV Dataset object using the URL specified in the UI. Then connects * with the dataset object to retrieve the column names. Updates the UI * accordingly.
()
| 77 | * accordingly. |
| 78 | */ |
| 79 | async function getColumnNamesHandler() { |
| 80 | ui.updateColumnNamesOutput([]); |
| 81 | const url = ui.getQueryElement().value; |
| 82 | ui.updateStatus(`Attempting to connect to CSV resource at ${url}`); |
| 83 | const myData = tf.data.csv(url); |
| 84 | ui.updateStatus('Got the data connection ... determining the column names'); |
| 85 | ui.updateColumnNamesMessage('Determining column names.'); |
| 86 | try { |
| 87 | const columnNames = await myData.columnNames(); |
| 88 | ui.updateStatus('Done getting column names.'); |
| 89 | ui.updateColumnNamesMessage(''); |
| 90 | ui.updateColumnNamesOutput(columnNames); |
| 91 | } catch (e) { |
| 92 | const errorMsg = `Caught an error retrieving column names from ${url}. ` + |
| 93 | `This URL might not be valid or might not support CORS requests.` + |
| 94 | ` Check the developer console for CORS errors.` + e; |
| 95 | ui.updateColumnNamesMessage(errorMsg); |
| 96 | return; |
| 97 | } |
| 98 | }; |
| 99 | |
| 100 | /** |
| 101 | * Accesses the CSV to collect a single specified row. The row index |
nothing calls this directly
no outgoing calls
no test coverage detected