Skip to content

Instantly share code, notes, and snippets.

@njlr
Created February 14, 2018 12:59
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 njlr/cde36e17d1a434bcf867dac51aa586e3 to your computer and use it in GitHub Desktop.
Save njlr/cde36e17d1a434bcf867dac51aa586e3 to your computer and use it in GitHub Desktop.
export const parseCsv = function * (symbols) {
let word = '';
let line = [];
for (const symbol of symbols) {
if (symbol == '\n') {
line.push(word);
yield line;
word = '';
line = [];
} else if (symbol == ',') {
line.push(word);
word = '';
} else {
word += symbol;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment