conversikit
Advanced tools
Comparing version 1.8.6 to 1.8.7
22
index.js
@@ -159,4 +159,2 @@ const fs = require('fs'); | ||
// console.log("data ==== ", data) | ||
// Split the CSV data into an array of rows | ||
const rows = data.split('\n'); | ||
@@ -170,3 +168,2 @@ const header = rows[0].split(','); | ||
// console.log("csvData == ", csvData) | ||
let obj = {}; | ||
@@ -178,7 +175,3 @@ let concatData = ""; | ||
for (let j = 0; j < csvData.length; j++) { | ||
// console.log("==========================================================") | ||
// console.log("csvData length === ", csvData.length); | ||
// console.log("data occure = ", dataOccur); | ||
// console.log("header length = ", header[j - dataOccur]) | ||
// console.log("--------------------------------------------------------") | ||
@@ -188,3 +181,3 @@ if (occure) { | ||
concatData += csvData[j]; | ||
obj[header[j - dataOccur]] = concatData || ""; | ||
obj[JSON.stringify(header[j- dataOccur].split('\r')[0])] = concatData || ""; | ||
concatData = ""; | ||
@@ -200,18 +193,19 @@ occure = false; | ||
if (csvData[j].startsWith('"')) { | ||
// console.log("data == ", csvData[j]) | ||
concatData += csvData[j] + ","; | ||
dataOccur++; | ||
occure = true; | ||
// console.log("oc json -- ", obj); | ||
continue; | ||
} | ||
if (header[j - dataOccur]) { | ||
obj[header[j - dataOccur]] = csvData[j] || ""; | ||
obj[JSON.stringify(header[j- dataOccur].split('\r')[0])] = csvData[j] || ""; | ||
} | ||
// console.log("ppp json -- ", obj); | ||
if(j === csvData.length -1){ | ||
obj[JSON.stringify(header[j- dataOccur].split('\r')[0])] = csvData[j].split('\r')[0] || ""; | ||
} | ||
} | ||
if (obj) jsonArray.push(obj) | ||
} | ||
// console.log("allll -------> ", jsonArray) | ||
return jsonArray; | ||
@@ -218,0 +212,0 @@ |
{ | ||
"name": "conversikit", | ||
"version": "1.8.6", | ||
"version": "1.8.7", | ||
"description": "convert anything", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
10678
173