Reputation: 402
I have .csv files that are updated periodically and I need to output the total row count in an .html file.
I'm not that bad when it comes to jQuery, but this I never did and really would use some help form someone that has any experience with this.
Upvotes: 2
Views: 9073
Reputation: 808
Read the csv file
var csvContents = getCsvContents(myFile);
Split the lines
var lines = csvContents.split('\n');
Get the count
lines.length
Example:
var myFileUri = "file.csv";
alertCsvCount(myFileUri);
function alertCsvCount(myFile){
//use jquery get
$.get(myFile, function(data) {
var lineCount = data.split('\n').length;
//do what you want to do in lineCount
alert(lineCount);
})
}
Upvotes: 4