pnpm
Version:
Fast, disk space efficient package manager
118 lines (117 loc) • 7.98 kB
JSON
{
"_args": [
[
{
"raw": "csv-parser@^1.6.0",
"scope": null,
"escapedName": "csv-parser",
"name": "csv-parser",
"rawSpec": "^1.6.0",
"spec": ">=1.6.0 <2.0.0",
"type": "range"
},
"/home/zoltan/src/pnpm/pnpm/packages/pnpm/node_modules/neat-csv"
]
],
"_from": "csv-parser@^1.6.0",
"_hasShrinkwrap": false,
"_id": "csv-parser@1.12.1",
"_location": "/csv-parser",
"_nodeVersion": "9.7.1",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/csv-parser_1.12.1_1521674183025_0.6800681395424022"
},
"_npmUser": {
"name": "mafintosh",
"email": "mathiasbuus@gmail.com"
},
"_npmVersion": "5.6.0",
"_phantomChildren": {},
"_requested": {
"raw": "csv-parser@^1.6.0",
"scope": null,
"escapedName": "csv-parser",
"name": "csv-parser",
"rawSpec": "^1.6.0",
"spec": ">=1.6.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/neat-csv"
],
"_resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-1.12.1.tgz",
"_shasum": "391e1ef961b1f9dcb4c7c0f82eb450a1bd916158",
"_shrinkwrap": null,
"_spec": "csv-parser@^1.6.0",
"_where": "/home/zoltan/src/pnpm/pnpm/packages/pnpm/node_modules/neat-csv",
"author": {
"name": "mafintosh"
},
"bin": {
"csv-parser": "./bin.js"
},
"bugs": {
"url": "https://github.com/mafintosh/csv-parser/issues"
},
"dependencies": {
"buffer-alloc": "^1.1.0",
"buffer-from": "^1.0.0",
"generate-function": "^1.0.1",
"generate-object-property": "^1.0.0",
"inherits": "^2.0.1",
"minimist": "^1.2.0",
"ndjson": "^1.4.0"
},
"description": "Streaming CSV parser that aims for maximum speed as well as compatibility with the csv-spectrum test suite",
"devDependencies": {
"bops": "^0.1.1",
"concat-stream": "^1.4.5",
"csv-spectrum": "^1.0.0",
"standard": "^5.4.1",
"tape": "^4.2.2"
},
"directories": {
"example": "examples",
"test": "test"
},
"dist": {
"integrity": "sha512-r45M92nLnGP246ot0Yo5RvbiiMF5Bw/OTIdWJ3OQ4Vbv4hpOeoXVIPxdSmUw+fPJlQOseY+iigJyLSfPMIrddQ==",
"shasum": "391e1ef961b1f9dcb4c7c0f82eb450a1bd916158",
"tarball": "https://registry.npmjs.org/csv-parser/-/csv-parser-1.12.1.tgz",
"fileCount": 6,
"unpackedSize": 14950
},
"gitHead": "d8791d38bc79a2239ede843bc352bf78ba92eebf",
"homepage": "https://github.com/mafintosh/csv-parser",
"keywords": [
"csv",
"parser",
"fast",
"json"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "mafintosh",
"email": "mathiasbuus@gmail.com"
},
{
"name": "maxogden",
"email": "max@maxogden.com"
}
],
"name": "csv-parser",
"optionalDependencies": {},
"readme": "# csv-parser\n\nStreaming CSV parser that aims for maximum speed as well as compatibility with the [csv-spectrum](https://npmjs.org/csv-spectrum) CSV acid test suite\n\n```\nnpm install csv-parser\n```\n\n[](http://travis-ci.org/mafintosh/csv-parser)\n\n\n`csv-parser` can convert CSV into JSON at at rate of around 90,000 rows per second (perf varies with data, try `bench.js` with your data).\n\n## Usage\n\nSimply instantiate `csv` and pump a csv file to it and get the rows out as objects\n\nYou can use `csv-parser` in the browser with [browserify](http://browserify.org/)\n\nLet's say that you have a CSV file ``some-csv-file.csv`` like this:\n\n```\nNAME, AGE\nDaffy Duck, 24\nBugs Bunny, 22\n```\n\nYou can parse it like this:\n\n``` js\nvar csv = require('csv-parser')\nvar fs = require('fs')\n\nfs.createReadStream('some-csv-file.csv')\n .pipe(csv())\n .on('data', function (data) {\n console.log('Name: %s Age: %s', data.NAME, data.AGE)\n })\n```\n\nThe data emitted is a normalized JSON object. Each header is used as the property name of the object.\n\nThe csv constructor accepts the following options as well\n\n``` js\nvar stream = csv({\n raw: false, // do not decode to utf-8 strings\n separator: ',', // specify optional cell separator\n quote: '\"', // specify optional quote character\n escape: '\"', // specify optional escape character (defaults to quote value)\n newline: '\\n', // specify a newline character\n strict: true // require column length match headers length\n})\n```\nIt accepts too an array, that specifies the headers for the object returned:\n\n``` js\nvar stream = csv(['index', 'message'])\n\n// Source from somewere with format 12312,Hello World\norigin.pipe(stream)\n .on('data', function (data) {\n console.log(data) // Should output { \"index\": 12312, \"message\": \"Hello World\" }\n })\n```\n\nor in the option object as well\n\n``` js\nvar stream = csv({\n raw: false, // do not decode to utf-8 strings\n separator: ',', // specify optional cell separator\n quote: '\"', // specify optional quote character\n escape: '\"', // specify optional escape character (defaults to quote value)\n newline: '\\n', // specify a newline character\n headers: ['index', 'message'] // Specifing the headers\n})\n```\n\nIf you do not specify the headers, csv-parser will take the first line of the csv and treat it like the headers.\n\nAnother issue might be the encoding of the source file. Transcoding the source stream can be done neatly with something like [`iconv-lite`](https://www.npmjs.com/package/iconv-lite), Node bindings to [`iconv`](https://www.npmjs.com/package/iconv) or native [`iconv`](http://man7.org/linux/man-pages/man1/iconv.1.html) if part of a pipeline.\n\n## Events\n\nThe following events are emitted during parsing.\n\n### data\n\nFor each row parsed (except the header), this event is emitted. This is already discussed above.\n\n### headers\n\nAfter the header row is parsed this event is emitted. An array of header names is supplied as the payload.\n\n```\nfs.createReadStream('some-csv-file.csv')\n .pipe(csv())\n .on('headers', function (headerList) {\n console.log('First header: %s', headerList[0])\n })\n```\n\n### Other Readable Stream Events\nThe usual [Readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) events are also emitted. Use the ``close`` event to detect the end of parsing.\n\n```\nfs.createReadStream('some-csv-file.csv')\n .pipe(csv())\n .on('data', function (data) {\n // Process row\n })\n .on('end', function () {\n // We are done\n})\n```\n\n## Command line tool\n\nThere is also a command line tool available. It will convert csv to line delimited JSON.\n\n```\nnpm install -g csv-parser\n```\n\nOpen a shell and run\n\n```\n$ csv-parser --help # prints all options\n$ printf \"a,b\\nc,d\\n\" | csv-parser # parses input\n```\n\n### Options\n\nYou can specify these CLI flags to control how the input is parsed:\n\n```\nUsage: csv-parser [filename?] [options]\n\n --headers,-h Explicitly specify csv headers as a comma separated list\n --output,-o Set output file. Defaults to stdout\n --separator,-s Set the separator character (\",\" by default)\n --quote,-q Set the quote character ('\"' by default)\n --escape,-e Set the escape character (defaults to quote value)\n --strict Require column length match headers length\n --version,-v Print out the installed version\n --help Show this help\n```\n\nFor example, to parse a TSV file:\n\n```\ncat data.tsv | csv-parser -s $'\\t'\n```\n\n## Related\n\n- [neat-csv](https://github.com/sindresorhus/neat-csv) - Promise convenience wrapper\n\n## License\n\nMIT\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/mafintosh/csv-parser.git"
},
"scripts": {
"test": "standard && tape test/test.js"
},
"version": "1.12.1"
}