Skip to content

Instantly share code, notes, and snippets.

@edouard-claude
Last active April 17, 2019 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edouard-claude/fd60e011e3e5b02f000ad41da38788b1 to your computer and use it in GitHub Desktop.
Save edouard-claude/fd60e011e3e5b02f000ad41da38788b1 to your computer and use it in GitHub Desktop.
example for Medium post
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