
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
magic-csv is an automagic CSV parser designed to handle whatever you throw at it
Usage
MagicCSV = require("magic-csv");
csv = new MagicCSV({trim: true});
// file example
csv.readFile("example.csv", function(err, stats) {
csv.getCols(); // ['First', 'Last', 'Pain']
csv.getRow(0); // ['Brian', 'Regan', '8']
csv.getObject(0); // {First: 'Brian', Last: 'Regan', Pain: '8'}
csv.getStats(); // stats object, detailing how the file was parsed
csv.getRowCount(); // same as stats.row_count
});
// objects example
var ob1 = {Name: 'Jimmy', Phone: 5552497, Gender: 'M'};
var ob2 = {Name: 'Justin', Phone: 5553546, Phone2: 5557951, Gender: 'M'};
csv.readObjects([ob1, ob2], function(err, stats) {
csv.getCols(); // ['Name', 'Phone', 'Phone2', 'Gender']
csv.getRow(0); // ['Jimmy', '5552497', '', 'M']
csv.getRow(1); // ['Justin', '5553546', '5557951', 'M']
csv.getCol('Phone'); // ['5552497', '5553546']
});
// raw example
csv.parse(str, function(err, stats) {
csv.getRow(-1); // last row
csv.getRows(); // all rows
csv.getObjects(); // all objects
csv.getColCount(); // same as stats.col_count
});
// write methods
csv.writeToStream(stream);
csv.writeToRes(res, 'out.csv'); // express response
csv.writeToFile('out.csv');
FAQs
Robust CSV parser with format detection
We found that magic-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.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.