Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda