writing Float32Array to sd and read back ?

Posted on
  • I would like to write an array fo Float32Array to sd and read it back later.
    What is the best way to do this ?

  • It depends on the size of the array I guess, and whether you want it human readable or not.


    // write
    fs.writeFileSync("foo.txt", array.toString());
    // read
    array = new Float32Array(JSON.parse(fs.readFileSync(­"foo.txt")));


    // write
    fs.writeFileSync("foo.bin", E.toString(array.buffer));
    // read
    array = new Float32Array(E.toArrayBuffer(fs.readFile­Sync("foo.txt")));

    For bigger arrays binary would be better, and for very big arrays you'd be looking at multiple save calls.

  • Wow, can't even write my questions as fast as your feedback is comin.
    Thanks a lot.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

writing Float32Array to sd and read back ?

Posted by Avatar for JumJum @JumJum