(rows, delimiter, hasHeaders)
| 17723 | } |
| 17724 | // Given an array return a particle |
| 17725 | static _rowsToParticle(rows, delimiter, hasHeaders) { |
| 17726 | const numberOfColumns = rows[0].length |
| 17727 | const particle = new Particle() |
| 17728 | const names = this._getHeader(rows, hasHeaders) |
| 17729 | const rowCount = rows.length |
| 17730 | for (let rowIndex = hasHeaders ? 1 : 0; rowIndex < rowCount; rowIndex++) { |
| 17731 | let row = rows[rowIndex] |
| 17732 | // If the row contains too many columns, shift the extra columns onto the last one. |
| 17733 | // This allows you to not have to escape delimiter characters in the final column. |
| 17734 | if (row.length > numberOfColumns) { |
| 17735 | row[numberOfColumns - 1] = row.slice(numberOfColumns - 1).join(delimiter) |
| 17736 | row = row.slice(0, numberOfColumns) |
| 17737 | } else if (row.length < numberOfColumns) { |
| 17738 | // If the row is missing columns add empty columns until it is full. |
| 17739 | // This allows you to make including delimiters for empty ending columns in each row optional. |
| 17740 | while (row.length < numberOfColumns) { |
| 17741 | row.push("") |
| 17742 | } |
| 17743 | } |
| 17744 | const obj = {} |
| 17745 | row.forEach((atomValue, index) => { |
| 17746 | obj[names[index]] = atomValue |
| 17747 | }) |
| 17748 | particle.pushContentAndSubparticles(undefined, obj) |
| 17749 | } |
| 17750 | return particle |
| 17751 | } |
| 17752 | static _initializeXmlParser() { |
| 17753 | if (this._xmlParser) return |
| 17754 | const windowObj = window |
no test coverage detected