Here I am using .CSV file in phonegap application for one application.
I have 25 .CSV files.
I want to get full all 25 .CSVs in my application.
for my reference but it takes from input. i dont want to get file from user input. i want to get file directly from www folder.
$(document).ready(function () {
if (isAPIAvailable()) {
$('#files').bind('change', handleFileSelect);
}
});
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
//var files = new array['C:\Users\Bhavdip Bhalodia\Desktop\raw\bc.csv'];
var file = "C:\Users\Bhavdip Bhalodia\Desktop\raw\bc.csv";
alert("file" + file);
// read the file metadata
var output = ''
output += '<span style="font-weight:bold;">' + escape(file.name) + '</span><br />\n';
output += ' - FileType: ' + (file.type || 'n/a') + '<br />\n';
output += ' - FileSize: ' + file.size + ' bytes<br />\n';
output += ' - LastModified: ' + (file.lastModifiedDate ? file.lastModifiedDate.toLocaleDateString() : 'n/a') + '<br />\n';
// read the file contents
printTable(file);
// post the results
$('#list').append(output);
}
function printTable(file) {
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function (event) {
var csv = event.target.result;
var data = $.csv.toArrays(csv);
var html = '';
for (var row in data) {
html += '<tr>\r\n';
for (var item in data[row]) {
html += '<td>' + data[row][item] + '</td>\r\n';
}
html += '</tr>\r\n';
}
$('#contents').html(html);
};
reader.onerror = function () {
alert('Unable to read ' + file.fileName);
};
}
UPDATE I dont want to read CSV manual change we want to take file from the path. without user prompting input.
In this example, input taking from user but i dont want. I went here also:
Thanks and sorry for my Grammar.