Created
October 23, 2019 05:54
-
-
Save lvterry/0c71e7e8ea872e00dfcd289a18be551f to your computer and use it in GitHub Desktop.
Use Papaparse to parse csv file
This file contains hidden or 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
$.get('/data.csv', success); | |
function success(data) { | |
var results = Papa.parse(data, { | |
header: true, | |
dynamicTyping: true | |
}); | |
var length = results.data.length; | |
var container = document.getElementById('photos'); | |
for(var i = length - 1; i >= 0; i--) { | |
var a = document.createElement('a'); | |
a.href = results.data[i].url; | |
a.innerText = results.data[i].title; | |
container.appendChild(a); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment