New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@erdii/csv2jsonstream

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@erdii/csv2jsonstream - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

51

csv2jsonstream.js

@@ -8,14 +8,45 @@ #!/usr/bin/env node

inputPath: process.argv[2],
notFirstLine: false,
inputStream: null,
get hasInputPath() {
return !!this.inputPath;
},
// stats
outLines: 0,
get notFirstLine() {
return this.outLines > 0;
},
};
if (!path.isAbsolute(state.inputPath)) {
state.inputPath = path.resolve(process.cwd(), state.inputPath);
if (state.hasInputPath) {
// normalize input path
if (!path.isAbsolute(state.inputPath)) {
state.inputPath = path.resolve(process.cwd(), state.inputPath);
}
state.inputStream = fs.createReadStream(state.inputPath, {
encoding: "utf8"
});
} else {
process.stdin.setEncoding("utf8");
state.inputStream = process.stdin;
}
state.inputFileStream = fs.createReadStream(state.inputPath);
// open output array
console.log("[");
Papa.parse(state.inputFileStream, {
// output a "]" before exiting
function exitHandler() {
console.log("]");
console.error(`Processed Lines: ${state.outLines}`);
process.exit();
}
process.on("SIGINT", function() {
console.error("Exiting because of SIGKILL...");
exitHandler();
});
// configure and start the csv parser
Papa.parse(state.inputStream, {
header: true,

@@ -28,9 +59,5 @@ dynamicTyping: true,

if (!state.notFirstLine) {
state.notFirstLine = true;
}
state.outLines++;
},
complete: () => {
console.log("]");
}
complete: exitHandler,
});
{
"name": "@erdii/csv2jsonstream",
"version": "0.0.3",
"version": "0.1.0",
"description": "the cheapest csv to json-array converter EVER!",

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

@@ -9,4 +9,9 @@ # csv2jsonstream

### installation
`npm i -g @erdii/csv2jsonstream`
### usage
`csv2jsonstream input.csv > output.json`
* Read csv from file: `csv2jsonstream input.csv > output.json`
* Read csv from stdin: `cat input.csv | csv2jsonstream > output.json`
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