Skip to content

Instantly share code, notes, and snippets.

@ismaelc
Created February 2, 2021 05:51
Show Gist options
  • Select an option

  • Save ismaelc/47c9ca41bea723b3a5a8a44df15c0eae to your computer and use it in GitHub Desktop.

Select an option

Save ismaelc/47c9ca41bea723b3a5a8a44df15c0eae to your computer and use it in GitHub Desktop.
// Formats data into key:array
function processData(arrayData) {
let processed = {};
for (let [i, [text, label]] of arrayData.entries()) {
// TODO: Deal with headers
if (i == 0 && this.excludeFirstRow) continue;
// Do not add empty rows
if (text.trim() == '' || label.trim() == '') continue;
if (label in processed) {
processed[label].push(text);
} else {
processed[label] = [text];
}
}
return processed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment