I would know how to read a two columned .csv file (it is in .txt format) without header like this:
52,10
53,23
66,45
..,..
34,67
and store the first and the second value of each line respectively into an 2D array var coords = [[52,10],[53,23],[66,44],....,[34,67]];
in order to work with them in other functions. they are about 500,000 lines, is there also a limit to store it in array?
This code, I found it and modified it but it loads the csv .txt file and display it in browser.
JS:
document.getElementById('polygon').onchange = function(){
var file = this.files[0];
var reader = new FileReader();
reader.onload = function(progressEvent)
{
// Read line-by-line
var lines = this.result.split('\n');
for(var line = 0; line < lines.length; line++){
document.write(lines[line]);
}
};
reader.readAsText(file);
};
Html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div>
Upload your polygon's file:
<br>
<br>
<input type="file" name="file" id="polygon">
</div>
</body>
</html>
Then I can do for-loop to print or do what I want with these 2D array elements
Note: without jquery, just pure JS