I need to send a large JSON file from Node to Python. I can create the child_process with spawn to call the Python file, but I can't work out how to send the data to it. I've tried using pipe, but I'm not understanding the documentation.
Code:
var dataset = JSON.stringify(doc.data);
// Call the python API
try {
var py = require('child_process').spawn('python3', ['api.py', analysis, input]);
} catch(error) {
console.log(error);
}
// Pipe the data to the Python module
py.stdin.pipe(fs.createWriteStream(dataset));
py.stdin.end();
Error:
Uncaught Error: ENAMETOOLONG: name too long, open [file data printed to console here]