Last active
November 18, 2020 08:10
-
-
Save alexkrolick/aa00171d085d94683c74bf89f4198b0d to your computer and use it in GitHub Desktop.
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
// this is a very naive parser that only works on simple tables | |
// - no nesting | |
// - no cells that contain \t (tab) characters | |
// Usage: | |
// tsv` | |
// "Name" \t "Price" | |
// "Apple" \t 2.50 | |
// ` | |
function tsv(strings, ...expressions) { | |
const rows = strings.join("").split("\n"); | |
// const data = rows.map(row => row.split("\t").map(v => JSON.parse(v.trim()))); | |
const data = rows.map(row => row.split("\t").map(v => v.trim())); | |
return data; | |
} | |
export default tsv; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment