javascript - Loading CSV file with AlaSQL and JQuery -
i'm building html based app querying imported csv file using alasql. started this demo , tried implement same behavior setting onchange
event through jquery rather in tag. follow same pattern, , naively pass event forward loadfile
method. alternatively, tried handling alasql
request right in callback.
html:
<input id="with-jquery" name="with-jquery" type="file" />
javascript:
$('#with-jquery').on('change', function(event) { console.log('in jquery callback'); filename = $('#with-jquery').val(); console.log("filename: " + filename); alasql('select * file(?,{headers:true})',[event],function(res){ console.log('in alasql callback'); data = res; console.log(res); document.getelementbyid("jquery-result").textcontent = json.stringify(res); }); //loadfile(event); });
http://plnkr.co/edit/fowwvsw7zaugwv3bdbdn?p=preview
when try load file using jquery handler,
in jquery callback test.js:7 filename: c:\fakepath\sample.csv alasql.min.js:13 uncaught error: wrong usage of file() function
here questions:
- i can't find documentation alasql expects in
[event]
slot. - how
from file
method relate more specificfrom csv
,from xlsx
methods. - the wiki shows using
from csv
method supplying file name. can't imagine how work without supplying full path local file. can't browser. - the wiki recommends using "promise" format. how implement here?
Comments
Post a Comment