MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / getColumnNamesHandler

Function getColumnNamesHandler

data-csv/index.js:79–98  ·  view source on GitHub ↗

* 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.

()

Source from the content-addressed store, hash-verified

77 * accordingly.
78 */
79async 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected