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:

  1. i can't find documentation alasql expects in [event] slot.
  2. how from file method relate more specific from csv , from xlsx methods.
  3. the wiki shows using from csv method supplying file name. can't imagine how work without supplying full path local file. can't browser.
  4. the wiki recommends using "promise" format. how implement here?


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -