Skip to content

Instantly share code, notes, and snippets.

@lee2sman
Created October 1, 2022 21:20
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 lee2sman/c7d043ebdb0a3a6df98585394f2e5628 to your computer and use it in GitHub Desktop.
Save lee2sman/c7d043ebdb0a3a6df98585394f2e5628 to your computer and use it in GitHub Desktop.
No library required. Imports a TSV (tab separated value) text file, then splits it to an array of lines, each split into an array separated by tabs.
fetch("cal.tsv")
.then((response) => response.text())
.then((data) => {
//split text file by newline and tab
//thanks to stackoverflow https://stackoverflow.com/questions/47876718/splitting-text-file-by-newlines-and-tab-in-javascript
timetable_data = data.split("\n").map(function (ln) {
return ln.split("\t");
});
//returns array of timetable data by line, separated on each line by tab separated value
console.log(timetable_data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment