diff --git a/src/index.ts b/src/index.ts index d308068..c08c2d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,9 +37,10 @@ async function readCSV(csvFileName = "", batchSize: number = 0) { }); const linesArray = data.split(/\r|\n/).filter((line) => line); const columnNames = linesArray?.shift()?.split(",") || []; - let beginSQLInsert = `INSERT INTO ${fileAndTableName} (`; - columnNames.forEach((name) => (beginSQLInsert += `${name}, `)); - beginSQLInsert = beginSQLInsert.slice(0, -2) + ")\nVALUES\n"; + + // Improved string manipulation using array join + const beginSQLInsert = `INSERT INTO ${fileAndTableName} (${columnNames.join(', ')})\nVALUES\n`; + let values = ""; linesArray.forEach((line, index) => { // Parses each line of CSV into field values array