...
createFileReader = (fun=console.log,target=document.body)=>{
let ip = document.createElement('input')
target.appendChild(ip)
ip.type='file'
readFile=(evt)=>{
let file = evt.target.files[0]
console.log('file:',file)
let reader = new FileReader();
reader.readAsText(file);
reader.onload = function() {
let txt=reader.result // the text content of the file
// you can now process the txt with your own fun
fun(txt)
};
}
ip.onchange=readFile
}
myFun=(txt)=>{ // example of a function to parse a txt table into an array, dt
dt=txt.split(/[\n\r]+/)
.map(x=>x.split(/\t/))
}
Observable: https://observablehq.com/@observablehq/working-with-sql?collection=@observablehq/sql#cell-16, https://observablehq.com/@observablehq/working-with-sql?collection=@observablehq/sql
mimicking pandas in js: https://danfo.jsdata.org with support for TensorFlow.