Skip to content

Instantly share code, notes, and snippets.

@lvterry
Created October 23, 2019 05:54
Show Gist options
  • Save lvterry/0c71e7e8ea872e00dfcd289a18be551f to your computer and use it in GitHub Desktop.
Save lvterry/0c71e7e8ea872e00dfcd289a18be551f to your computer and use it in GitHub Desktop.
Use Papaparse to parse csv file
$.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