Last active
September 9, 2015 06:00
-
-
Save jamenlyndon/b69f16743a5d1ead16d6 to your computer and use it in GitHub Desktop.
Get data from periscope
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
// 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