csvparser-customlib
Advanced tools
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; | ||
}; |
{ | ||
"name": "csvparser-customlib", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A csv parser lib", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
1152
31
0
2