-
Notifications
You must be signed in to change notification settings - Fork 664
How to upload and parse CSV file from server and from desktop
Mathias Rangel Wulff edited this page Nov 24, 2016
·
6 revisions
You can use [AlaSQL][1] library to load and parse CSV data from server or from desktop.
####From Server You can and parse data with CSV() function:
alasql('SELECT * FROM CSV("mydata.csv",{headers:true})',[],function(data) {
// Use data
});
####From Desktop If you want to upload data from desktop you can use the following code:
<script src="alasql.min.js"></script>
<p>Select CSV file to read:</p>
<input id="readfile" type="file" onchange="loadFile(event)"/>
<script>
function loadFile(event) {
alasql('SELECT * FROM FILE(?,{headers:true})',[event],function(data){
// Process data here
});
}
</script>
See this jsfiddle for a live example
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo