logic-unit logic-unit - 11 months ago 103
Node.js Question

Send large JSON string from NodeJS to Python

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.


var dataset = JSON.stringify(doc.data);

// Call the python API
try {
var py = require('child_process').spawn('python3', ['api.py', analysis, input]);
} catch(error) {

// Pipe the data to the Python module


Uncaught Error: ENAMETOOLONG: name too long, open [file data printed to console here]

Answer Source

Here is a pretty good guide on what you are trying to do!

Seems like you also should do py.stdin.write('json data');