Socket
Socket
Sign inDemoInstall

csvparser-customlib

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

39

index.js
const fs = require('fs');
/**
* Parse CSV File Data
* @filePath {string} file source path
* @return {array}
*/

@@ -11,24 +13,21 @@ exports.parseData = (filePath) => {

.split('\n') // split string lines
.map(e => e.trim()); // remove white spaces for each line
const data = [];
csvContent.forEach((value) => {
const row = value.split(';');
if (row.length > 1) {
data.push(row);
}
row.forEach((rowData) => {
if (rowData) {
if (rowData.charAt(0) === '"' && rowData.charAt(rowData.length - 1) === '"') {
rowData = rowData.toString();
console.log(`Converted into a String : ${rowData}`);
} else {
console.log(`Converted into a Number : ${rowData}`);
rowData = Number.parseInt(rowData, 0);
.map(e => e.trim()) // remove white spaces for each line
.map((value) => {
const row = value.split(';');
row.map((rowData) => {
if (rowData) {
if (rowData.charAt(0) === '"' && rowData.charAt(rowData.length - 1) === '"') {
rowData = rowData.toString();
console.log(`Converted into a String : ${rowData}`);
} else {
console.log(`Converted into a Number : ${rowData}`);
rowData = Number.parseInt(rowData, 0);
}
}
}
return rowData;
return rowData;
});
return row;
});
});
return data;
return csvContent;
};
{
"name": "csvparser-customlib",
"version": "1.0.1",
"version": "1.0.2",
"description": "A csv parser lib",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc