javascript를 사용하여 내용을 CSV 형식으로 된 txt 파일을 읽은 다음 구문 분석하고 단일 배열로로드 할 수 있도록 노력하고 있습니다. 수학 연산을 (합계, 평균, 표준 편차) 좋아하십시오. 지금까지 텍스트 파일을 읽었을 때 파싱에 대한 도움이 필요했습니다.자바 스크립트를 사용하여 csv txt 파일을 읽고 배열에 결과로드
감사합니다. 콘텐츠는 또한 예를 들어 새로운 라인으로 구분되어있는 경우
inputExample.txt
5,4,4,4,4
3,3,3,3,2
1,5,4,7,6
index.html을
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<input type="file" id="openFile" />
<br>
<pre id="fileContents"></pre>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
는
document.getElementById("openFile").addEventListener('change', function(){
var fr = new FileReader();
fr.onload = function(){
// document.getElementById("fileContents").textContent = this.result;
console.log(this.result);
}
fr.readAsText(this.files[0]);
})
가능한 중복 : http://stackoverflow.com/a/12289296/1743938 –