Skip to content

Instantly share code, notes, and snippets.

@mechamogera
Created July 2, 2012 12:23
Show Gist options
  • Save mechamogera/3032990 to your computer and use it in GitHub Desktop.
Save mechamogera/3032990 to your computer and use it in GitHub Desktop.
最終行の最初のカラムを数値として取得するjavascriptのサンプル
function getCsvLastLineFirstColumnValue(text) {
var lines = text.split("\n");
var i = 0;
for (i = 0; i < lines.length; i++) {
var items = lines[lines.length - 1 -i].split(",");
var val = parseInt(items[0].replace("\"", ""));
if (isFinite(val)) { // <= NG: val != Number.NaN
return val;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment