Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
Sending data to psql from node

I had an excel file that I managed to read in the NodeJS, here is the excel format:

enter image description here

I have no header, only 4 columns. And the code I used is the following:

const { Client } = require("pg");
const xlsx = require("node-xlsx");

var data = xlsx.parse(__dirname + "/disease_data.xlsx");

var diseaseCode = [];
var disease = [];
var symptomCode = [];
var symptom = [];

const client = new Client({
  host: "localhost",
  user: "postgres",
  port: 5432,
  password: "dizertatie",
  database: "SymptomChecker",
});

client.connect();

for (var i = 0; i < data.length; i++) {
    var sheet = data[i];
    console.log(sheet["data"][i][1]);
    for (var j = 0; j < sheet["data"].length; j++) {
      //add the row to the rows array
      // diseaseCode.push(sheet["data"][j][0]);
      //Here is the problem
      client.query(`INSERT INTO diseases (diseaseCode, disease, symptomCode, symptom) VALUES ('${}')`)
    }
}

The problem is, I managed to stack each column from the excel into different arrays, but I don't know to push them corresponding line by line. What can I do?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!