2

I have large json data which I convert to CSV (using NPM jsonexport). Then I use NPM csv-parse to insert this CSV Data into mySQL table using NodeJS. However 1 extra row having the column names is also inserted in the mySQL Table. How can I eliminate this header row while converting to CSV data data itself (I am using jsonexport NPM to convert to CVS Data)

I tried all options in jsonexport and csv-parse such as : headers: false, noheader: true. But nothing is working

var mysql = require('mysql');
var  fs = require ('fs');
var jsonexport = require('jsonexport');
var csvParser = require('csv-parse');

jsonexport(QryResults, {headers: false}, function(err, csvdata) {...<still has the header record>

csvParser(csvdata, { delimiter: ',', noheader: true }, function(err, data) {...<still has the header record>

con.query("INSERT INTO my_tablename VALUES ?", [data], {...<header inserted>
Lord Elrond
  • 13,430
  • 7
  • 40
  • 80

0 Answers0