Skip to content

Instantly share code, notes, and snippets.

@YujiSODE
Created September 20, 2016 11:01
Show Gist options
  • Save YujiSODE/9f1c9db6fbc6d4445334902211c2be39 to your computer and use it in GitHub Desktop.
Save YujiSODE/9f1c9db6fbc6d4445334902211c2be39 to your computer and use it in GitHub Desktop.
it converts csv formatted text data into tab separated data for gnuplot.
//csv2GnuplotData.js
//it converts csv formatted text data into tab separated data for gnuplot
function csv2GnuplotData(title,csv){
var slf=this.window,_csvD=csv.split(/,/),N=_csvD.length,I=0,txt='#'+title+'\n'+'#N='+N+'\n';
var saveD=function(a){slf.location.href='data:application/octet-stream,'+encodeURIComponent(a);};
while(I<N){txt+=I+'\t'+_csvD[I]+'\n',I+=1;}
txt+='#EOF';
saveD(txt);
}
/* Copyright (c) 2016 Yuji SODE <yuji.sode@gmail.com>
* This is free. You can redistribute and/or modify it.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment