-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdi.min.js
1 lines (1 loc) · 937 Bytes
/
sdi.min.js
1
!function(t){t._shutdown=function(){},t._getStatus=function(){return{status:2,msg:"Ready"}},t.loadDataset=function(t,s,e,a,r){$.ajax({url:t,dataType:"text",success:function(t){for(var i=t.split("\n"),n=[],o=i[0].split(","),l=1;l<i.length;l++){for(var u=i[l].split(","),f={},h=0;h<u.length;h++)f[o[h].trim()]=u[h].trim();n.push(f)}for(var c=[],p=0;p<n.length;p++)c+=n[p][s]+a+n[p][e]+",";r(c)}})},t.shuffleList=function(t){var s,e,a;for(a=t.length-1;a>0;a--)s=Math.floor(Math.random()*(a+1)),e=t[a],t[a]=t[s],t[s]=e;return t},t.splitList=function(t,s,e){return t.split(s)[e]};ScratchExtensions.register("Dataset Importer extension",{blocks:[["R","Parse csv from %s where X is %s, Y is %s with seperator %s","loadDataset","https://itaysharon.github.io/cal_dataset.csv","total_rooms","median_house_value","|"],["r","Shuffle list %s","shuffleList",""],["r","Split list %s with seperator %s and get item #%n","splitList","","|",0]]},t)}({});