Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda