Skip to content

Instantly share code, notes, and snippets.

@jamenlyndon
Last active September 9, 2015 06:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamenlyndon/b69f16743a5d1ead16d6 to your computer and use it in GitHub Desktop.
Save jamenlyndon/b69f16743a5d1ead16d6 to your computer and use it in GitHub Desktop.
Get data from periscope
// Convert CSV to JS Obj
function csvToObj(csv) {
var lines = csv.split("\n");
var result = [];
var headers = lines[0].split(",");
for (var i = 1; i < lines.length; i++) {
var obj = {};
var currentline = lines[i].split(",");
for (var j = 0; j < headers.length; j++) {
obj[headers[j]] = currentline[j];
}
result.push(obj);
}
return result;
}
// Get periscope data (requires jQuery)
$.ajax({
type: "GET",
url: "https://www.periscope.io/api/everyday-hero/chart/csv/c1d30a15-4859-6f04-df9f-aedc880d33b1/6814",
dataType: 'text',
success: function(data) {
csvToObj($.trim(data));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment