Last active
April 17, 2019 11:10
-
-
Save edouard-claude/fd60e011e3e5b02f000ad41da38788b1 to your computer and use it in GitHub Desktop.
example for Medium post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sheetsToArray = (data) => { | |
let i, j, ilen, jlen | |
let dataSafe = [] | |
let columnNames = [] | |
if (undefined !== data && data.length){ | |
for(let key in data[0]){ | |
if(/^gsx/.test(key)){ | |
columnNames.push(key.replace("gsx$","")); | |
} | |
} | |
for(i = 0, ilen = data.length ; i < ilen; i++) { | |
let source = data[i]; | |
let item = {}; | |
for(j = 0, jlen = columnNames.length; j < jlen ; j++) { | |
let cell = source[ "gsx$" + columnNames[j] ]; | |
item[columnNames[j]] = cell.$t; | |
} | |
dataSafe.push(item); | |
} | |
} | |
return dataSafe | |
}; | |
export { sheetsToArray } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment