MCPcopy Index your code
hub / github.com/NUKnightLab/TimelineJS3 / processCSVRows

Function processCSVRows

src/js/core/ConfigFactory.js:150–173  ·  view source on GitHub ↗

* Process an array of CSV row objects into a timeline configuration. * This is the common logic used by both Google Sheets and direct CSV file reading. * * @param {Array} rows - Array of row objects from CSV parsing * @returns {Object} timeline configuration object with events, errors, warnings,

(rows)

Source from the content-addressed store, hash-verified

148 * @returns {Object} timeline configuration object with events, errors, warnings, and eras
149 */
150function processCSVRows(rows) {
151 let timeline_config = { 'events': [], 'errors': [], 'warnings': [], 'eras': [] }
152
153 rows.forEach((row, i) => {
154 try {
155 if (!isEmptyObject(row)) {
156 let event = extractEventFromCSVObject(row)
157 handleRow(event, timeline_config)
158 }
159 } catch (e) {
160 if (e.constructor == TLError) {
161 timeline_config.errors.push(e);
162 } else {
163 if (e.message) {
164 e = e.message;
165 }
166 let label = row['Headline'] || i
167 timeline_config.errors.push(e + `[${label}]`);
168 }
169 }
170 });
171
172 return timeline_config
173}
174
175/**
176 * Given a Google Sheets URL (or mere document ID), read the data and return

Callers 2

readGoogleAsCSVFunction · 0.85
readCSVFromURLFunction · 0.85

Calls 3

isEmptyObjectFunction · 0.90
handleRowFunction · 0.85

Tested by

no test coverage detected