How to save observable outputs (.csv and .png) in local drive?

Dear All,
I’m trying to save the output of the “Dup[r]” into .csv files (one new file for each iteration) on our local drive. I can see the results when using “console.log(Dup[r])” but I want the result will be automatically saved in .csv format on the specified location of my hard disk. Any input will be helpful.
On a different note, if I want to save images in .png, what will be the steps?

Thanks!

{
 for (var p=0; p<Csort.length; p++) {
   for(var q=0; q<Csort[p].length; q++){
     for (var r=0; r<Dup.length; r++) {
       if ((Dup[r]["Row"]=p) && (Dup[r]["Col"]=q)) {
         #console.log(Csort[p][q]);
         console.log(Dup[r]);
         //ctxxx.putImageData(canvas.getContext('2d').getImageData(Csort[p][q]["x"], Csort[p][q]["y"], 75, 75), 0, 0); 
       }
       
     }
     
     }
   }
     
  
}

maybe helpful? Using files with browsers, in reality - macwright.com

1 Like

I recently used Filesaver FileSaver = require('https://bundle.run/file-saver@2.0.5') For automatic file saving.

Had to add a delay between saves to not flood the system

sleep = ms => new Promise(r => setTimeout(r, ms));

Usage here: key typing dataset / Brett Cooper / Observable