Created
December 17, 2015 05:07
-
-
Save koolii/2b10b7e27caa99669678 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var formatter = function(csv) { | |
var lines = csv.split("\n"); | |
var result = []; | |
for (var i=0; i<lines.length;i++) { | |
var array = str.split(","); | |
var lineResult = []; | |
for (var i=0; i<array.length; i++) { | |
var strVal = array[i]; | |
// 小数点第二位まで表示されていたら | |
if (strVal.indexOf("%") != -1) { | |
// 小数点第一位にまで丸める | |
strVal = parseFloat(strVal.slice(0, strVal.length - 1)).toFixed(1); | |
strVal = strVal + "%"; | |
} | |
lineResult.push(strVal); | |
} | |
result.push(lineResult.join(",")); | |
} | |
return result.join("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment