我有大型 json 数据,我将其转换为 CSV(使用 NPM jsonexport)。然后我使用 NPM csv-parse 将此 CSV 数据插入到使用 NodeJS 的 mySQL 表中。但是,在 mySQL 表中还插入了 1 个额外的具有列名的行。如何在转换为 CSV 数据数据本身时消除此标题行(我正在使用 jsonexport NPM 转换为 CVS 数据)
我尝试了 jsonexport 和 csv-parse 中的所有选项,例如:headers: false, noheader: true。但没有任何工作
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>