* 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)
| 148 | * @returns {Object} timeline configuration object with events, errors, warnings, and eras |
| 149 | */ |
| 150 | function 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 |
no test coverage detected