I want to display specific fields from an external CSV file on a web site with using JavaScript. I tried to parse that file with using "Papa parse" like this:
<!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <title>Parse remote CSV to HTML Page</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script src='http://d3js.org/d3.v3.min.js'></script> <script src='https://code.jquery.com/jquery-2.1.4.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/PapaParse/4.1.2/papaparse.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.2.0/mustache.min.js'></script> <script> Papa.parse("https://dl.dropboxusercontent.com/s/....../data.csv?dl=0", { download: true, header: true, complete: function(results) { console.log(results); } }); </script> </body> </html>
And this give me the result in console:
My question is; How can I display a specific data from this data set in a web site like:
Battery Level: 0.62
Altimeter Pressure: 99.44185
Horizontal Accuracy: 65
etc. etc.
Taking Battery Level as an example (the other fields are similar and you should be able to figure it out youself):
var data = results.data
var arrayLength = data.length;
for (var i = 0; i < arrayLength; i++) {
var newdiv = document.createElement('div');
newdiv.setAttribute('id', 'your_div_id_'+i.toString());
newdiv.innerHTML = 'Battery Level: '+data[i].batteryLevel.toString();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.