Read .csv file from JavaScript

aleppo-it

New Member
I have a Phone gap project. In that project, I want to read a .csv file in my Android SD card and display file data in a table. Please give me a complete code to read that .csv file using JavaScript. Tried with lot of posts in here. But didn't work. Your help will be really appreciated. EDIT: I used below code. There is a myfile.csv file in "Files" folder in my memory card. And I noticed that "processData" function is not called. I tested by adding a alert.\[code\]$(document).ready(function() { $.ajax({ type: "GET", url: "/Files/myfile.csv", dataType: "text", success: function(data) {processData(data);} });});function processData(allText) { var record_num = 5; var allTextLines = allText.split(/\r\n|\n/); var entries = allTextLines[0].split(','); var lines = []; var headings = entries.splice(0,record_num); while (entries.length>0) { var tarr = []; for (var j=0; j<record_num; j++) { tarr.push(headings[j]+":"+entries.shift()); } lines.push(tarr); } // alert(lines);}\[/code\]Thank you very much..!!
 
Back
Top