mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-10 12:28:34 +03:00
22 lines
507 B
JavaScript
22 lines
507 B
JavaScript
import { fmtObj } from '../lib/util'
|
|
|
|
/**
|
|
* Each resource item is an object with values labelled according
|
|
* to column names specified in the sheet's first row.
|
|
*
|
|
* @param {type} data list of lists representing sheet data.
|
|
* @return {type} Array the structured data.
|
|
*/
|
|
export default (data) => {
|
|
const itemLabels = data[0]
|
|
const fmt = fmtObj(itemLabels)
|
|
const output = []
|
|
|
|
data.forEach((row, idx) => {
|
|
if (idx === 0) return
|
|
output.push(fmt(row))
|
|
})
|
|
|
|
return output
|
|
}
|