Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@coolgk/csv
Advanced tools
a javascript / typescript module
npm install @coolgk/csv
read and write csv files
Report bugs here: https://github.com/coolgk/node-utils/issues
import { Csv } from '@coolgk/csv';
// OR
// const { Csv } = require('@coolgk/csv');
const csv = new Csv({
tmpConfig: { dir: '/tmp/csv' } // optional
});
const arrayData = [
[1,2,3,4,5],
[6,7,7,8,9],
[0,5,8,90,65]
];
const objectData = [
{col1: 'ab', col2: 'cd', col3: 'ef'},
{col1: '2ab', col2: '2cd', col3: '2ef'},
{col1: '3ab', col2: '3cd', col3: '3ef'}
];
csv.createFile(
arrayData,
{
columns: ['column 1', 'column 2', 'column 3', 'h4', 'h5'],
formatter: (row) => {
return row.map((value) => 'formatted-' + value);
}
}
).then((csvFilePath) => {
console.log(csvFilePath); // /tmp/csv/151229255018910356N9qKqUgrpzG2.csv
read(csvFilePath, ['column 1', 'column 2', 'column 3', 'h4', 'h5']);
});
csv.createFile(
objectData,
{
columns: ['col1', 'col2', 'col3'],
formatter: (row) => {
return [row.col1 + '+format', row.col2 + '+format', row.col3 + '+format'];
}
}
).then((csvFilePath) => {
console.log(csvFilePath); // /tmp/csv/151229255019910356AlO9kbzkdqjq.csv
read(csvFilePath, ['col1', 'col2', 'col3']);
});
function read (file, columns) {
// with columns/headers
// read lines as object
const lines = csv.readFile(file, {columns: columns});
lines.forEach(
(lineArray, index) => {
console.log(lineArray, index);
// {
// 'column 1': 'formatted-1',
// 'column 2': 'formatted-2',
// 'column 3': 'formatted-3',
// h4: 'formatted-4',
// h5: 'formatted-5'
// } 1
},
(total) => {
console.log('read done, total:', total); // read done, total: 4
}
);
// without columns/headers
// read lines as array
const lines2 = csv.readFile(file);
lines2.forEach(
(lineArray, index) => {
console.log(lineArray, index); // [ 'formatted-1', 'formatted-2', 'formatted-3', 'formatted-4', 'formatted-5' ] 1
},
(total) => {
console.log('read done, total:', total); // read done, total: 4
}
);
}
FAQs
read and write csv files
The npm package @coolgk/csv receives a total of 5 weekly downloads. As such, @coolgk/csv popularity was classified as not popular.
We found that @coolgk/csv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.