Last active
March 31, 2019 06:24
-
-
Save sanusart/2a4237a9c43a6335186dda93b465effc to your computer and use it in GitHub Desktop.
TSV to object #tsv #csv #lodash
This file contains hidden or 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
export const tsvToObject = () => | |
fetch('https://www.file.com/some.tsv') | |
.then(r => r.text()) | |
.then(tsv => { | |
const data = compact(tsv.split('\n')); | |
const headers = head(data).split('\t'); | |
const rows = map(row => row.split('\t'), tail(data)); | |
return keyBy('SOME_HEADER', rows.map(m => zipObject(headers, m))); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment