Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

csvparser-customlib

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csvparser-customlib - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

35

index.js

@@ -1,4 +0,33 @@

exports.parseCsv = function() {
console.log("csv parser lib");
}
const fs = require('fs');
/**
* Parse CSV File Data
*/
exports.parseData = (filePath) => {
console.log(`Reading File : ${filePath}`);
const csvContent = fs.readFileSync(filePath, 'utf8')
.toString() // convert to string
.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);
}
}
return rowData;
});
});
return data;
};

2

package.json
{
"name": "csvparser-customlib",
"version": "1.0.0",
"version": "1.0.1",
"description": "A csv parser lib",

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc