I searched a lot here in Stack Overflow and in Google but unfortunately no answer.
I wrote a code in JS, it give me such a "expectable and correct" result:
W,52.xxxxx,10.1
W,52.xxxxx,10.2
W,52.xxxxx,10.3
W,52.yyyyy,10.1
W,52.yyyyy,10.2
W,52.yyyyy,10.3
The problem is that there is a too large list of such rows, I can't copy it fully in Android, so I would to save this list as csv file instead to display it on the webpage via the command
"document.write"
I modified my code with the help of other peoples' codes but it doesnt work. I become the word "undefined" instead of the list of data that would be inside the csv file :(
Code is here:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
<script>
function convertTo()
{
var lon,lat;
for(lat = 52 + (1/3600) ; lat <= 52 + (3/3600) ; lat=lat+(1/3600))
{
for(lon = 9 + (1/3600) ; lon<= 9 + (4/3600) ; lon=lon+(1/3600))
{
document.write("W,"+lat+","+lon+"<br>")
}
}
};
var CSV = convertTo();
window.URL = window.webkitURL || window.URL;
var contentType = 'text/csv';
var csvFile = new Blob([CSV], {type: contentType});
var a = document.createElement('a');
a.download = 'my.csv';
a.href = window.URL.createObjectURL(csvFile);
a.textContent = 'Download as CSV';
a.dataset.downloadurl = [contentType,
a.download, a.href].join(':');
document.body.appendChild(a);
</script>
</html>
Any help please!
Hint: I am beginner with JS
Edit: Here I got the code the export into csv file the I added and modified with my code: