2

I have read this code but an error is coming. I am trying to send a read CSV file from Express.js to Python but getting an error.

The error is:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at _errnoException (util.js:1022:11)
    at Pipe.onread (net.js:628:25) 

Here is my Python code:

import sys
print(sys.stdin)
filename = sys.stdin.read()
read_DataChunks(filename))# to read filename and process data

Here is my Express code:

router.post("/Postapi",(req,res)=>{

    upload(req,res,(err)=>{

        if (!req.file){
            return res.json({file:"Did you Upload FIle? Go back and upload File"})
        }
        if(err){
            return res.status(500).send({error:err.message});
        }
    
   
        let pyShelll = new PythonShell("./pythonScripts/MCAGov.py",{mode:"text"})

        fs.createReadStream("./uploads/"+req.file.filename)// file goes to upload folder ,is it correct?
        .pipe(csv())
        .on('data', (row) => {
            pyShelll.send(row)
        });

        res.render("hander")
    })

    // res.json({message:"Sent"})
})
2
  • is this full error message? Do you have this problem when you don't send to Python? Maybe you should check what you have in variables - I don't know if you can use console.log() or alert() in Express. You could also use it to see which line makes problem - if you don't have this information in error message. Commented Apr 29, 2021 at 8:12
  • 1
    this is the full error message sir.No i dont face any problem when i dont send to python. Commented Apr 29, 2021 at 8:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.