What is the correct way to write an image in a csv/xlsx file?
<p>I am trying to write an image, into a csv file. The script writes the file, but the contents of the image are messed up.
Long sequence of <code>����\u0000\u0010JFIF\u0000\u0001\u0001</code>.
Can someone point out what i am missing with the encoding or should i be doing something else?</p>

<p>To test:
<code>mkdir so-38711430; cd so-38711430; npm init -y; npm i -S lodash json2csv;</code></p>

<pre><code>'use strict';

const _ = require('lodash');
const json2csv = require('json2csv');
const fs = require('fs');

let rows = [
    {
        'id': 1,
        'name': '12323',
    },
    {
        'id': 2,
        'name': '22323',
    },
    {
        'id': 3,
        'name': '323232',
    },
    {
        'id': 4,
        'name': '24242',
    },
];

// image path is valid
fs.readFile(`./images/2NTSFr7.jpg`, 'utf-8', (err, data) =&gt; {
    _.each(rows, (item) =&gt; {
        item.image = data;
    });

    json2csv({
        'data': rows
    }, (err, csv) =&gt; {
        fs.writeFile('file.csv', csv, (err) =&gt; {
            if (err) throw err;

            console.log('file saved');
        });
    });
});
</code></pre>