{"_id":"parse-csv","_rev":"86407","name":"parse-csv","description":"CSV parser for node.js.","dist-tags":{"latest":"0.2.0"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T10:28:03.000Z","created":"2014-11-22T01:36:40.838Z","0.2.0":"2016-05-09T06:11:51.033Z","0.1.0":"2014-11-22T01:36:40.838Z"},"users":{},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/parse-csv.git"},"versions":{"0.2.0":{"name":"parse-csv","description":"CSV parser for node.js.","version":"0.2.0","homepage":"https://github.com/jonschlinkert/parse-csv","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/parse-csv.git"},"bugs":{"url":"https://github.com/jonschlinkert/parse-csv/issues"},"license":"MIT","files":["index.js","lib"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","is-number":"^2.1.0","isobject":"^2.1.0","mixin-deep":"^1.1.3"},"devDependencies":{"gulp-format-md":"^0.1.9","mocha":"^2.4.5"},"keywords":["csv","parse"],"verb":{"plugins":["gulp-format-md"],"reflinks":["verb"],"toc":true,"layout":"default","lint":{"reflinks":true},"tasks":["readme"],"related":{"list":["parser-csv","gulp-convert"]}},"gitHead":"b7c05be301326d75b374151367a4cdb53db7582d","_id":"parse-csv@0.2.0","_shasum":"688c1e94b7340e2073ac8981fcbf2b38b67cb74c","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.5.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"688c1e94b7340e2073ac8981fcbf2b38b67cb74c","size":8369,"noattachment":false,"key":"/parse-csv/-/parse-csv-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/parse-csv/download/parse-csv-0.2.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/parse-csv-0.2.0.tgz_1462774308633_0.950859046773985"},"directories":{},"publish_time":1462774311033,"_cnpm_publish_time":1462774311033,"_hasShrinkwrap":false},"0.1.0":{"name":"parse-csv","description":"CSV parser for node.js.","version":"0.1.0","homepage":"https://github.com/jonschlinkert/parse-csv","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/parse-csv.git"},"bugs":{"url":"https://github.com/jonschlinkert/parse-csv/issues"},"licenses":[{"type":"MIT","url":"https://github.com/jonschlinkert/parse-csv/blob/master/LICENSE-MIT"}],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha -R spec"},"devDependencies":{"mocha":"*","should":"*"},"keywords":[],"dependencies":{"lodash":"^2.4.1"},"_id":"parse-csv@0.1.0","_shasum":"19d698bd74bd4429fbfa3f59e0227333b3864725","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"19d698bd74bd4429fbfa3f59e0227333b3864725","size":6989,"noattachment":false,"key":"/parse-csv/-/parse-csv-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/parse-csv/download/parse-csv-0.1.0.tgz"},"directories":{},"publish_time":1416620200838,"_cnpm_publish_time":1416620200838,"_hasShrinkwrap":false}},"readme":"# parse-csv [![NPM version](https://img.shields.io/npm/v/parse-csv.svg?style=flat)](https://www.npmjs.com/package/parse-csv) [![NPM downloads](https://img.shields.io/npm/dm/parse-csv.svg?style=flat)](https://npmjs.org/package/parse-csv) [![Build Status](https://img.shields.io/travis/jonschlinkert/parse-csv.svg?style=flat)](https://travis-ci.org/jonschlinkert/parse-csv)\n\nCSV parser for node.js.\n\n## TOC\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n  * [Available renderers](#available-renderers)\n- [Options](#options)\n  * [Parser options](#parser-options)\n  * [Renderer options](#renderer-options)\n- [Related projects](#related-projects)\n- [Contributing](#contributing)\n- [Building docs](#building-docs)\n- [Running tests](#running-tests)\n- [Author](#author)\n- [License](#license)\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install parse-csv --save\n```\n\nBased on [mr-data-converter](https://github.com/shancarter/mr-data-converter) by [@shancarter](https://github.com/shancarter). Copyright (c) 2011 Shan Carter.\n\n## Usage\n\n```js\nvar csv = require('parse-csv');\n\nvar str = [\n  'id,fruit,vegetable',\n  '1,apple,carrot',\n  '2,orange,corn',\n  '3,banana,potato'\n].join('\\n');\n\nvar obj = csv.toJSON(str, {headers: {included: true}});\nconsole.log(obj);\n```\n\n## API\n\n### [csv](index.js#L45)\n\nParse a string of CSV to a datagrid and render it using the specified [renderer](#renderer). The `.json` renderer is used by default.\n\n**Params**\n\n* `method` **{String}**: The name of the renderer method to use, or a string of CSV. If CSV, the `.json` method will be used.\n* `str` **{String|Object}**: String of CSV or options.\n* `options` **{Object}**\n* `returns` **{String}**\n\n**Example**\n\n```js\nvar str = `\nid,fruit,vegetable\n1,apple,carrot\n2,orange,corn\n3,banana,potato`;\n\nvar res = csv(str, {headers: {included: true}});\nconsole.log(res);\n// results in:\n// [{\"id\":\"1\",\"fruit\":\"apple\",\"vegetable\":\"carrot\"},\n// {\"id\":\"2\",\"fruit\":\"orange\",\"vegetable\":\"corn\"},\n// {\"id\":\"3\",\"fruit\":\"banana\",\"vegetable\":\"potato\"}]\n```\n\n### [.toJSON](index.js#L90)\n\nParse a string of CSV to a datagrid, format it using one of the `.json*` [renderer](#renderer) methods, then parse it back to JSON.\n\n**Params**\n\n* `method` **{String}**: The name of the renderer method to use, or a string of CSV. If CSV, the `.json` method will be used.\n* `str` **{String|Object}**: String of CSV or options.\n* `options` **{Object}**\n* `returns` **{String}**\n\n**Example**\n\n```js\nvar str = `\nid,fruit,vegetable\n1,apple,carrot\n2,orange,corn\n3,banana,potato`;\n\nvar res = csv.toJSON('jsonDict', str, {headers: {included: true}});\nconsole.log(res);\n// results in:\n// { '1': { fruit: 'apple', vegetable: 'carrot' },\n//   '2': { fruit: 'orange', vegetable: 'corn' },\n//   '3': { fruit: 'banana', vegetable: 'potato' } }\n```\n\n### [Parser](lib/parser.js#L30)\n\nCreate a new `Parser` with the given `options`.\n\n**Params**\n\n* `options` **{Options}**\n\n**Example**\n\n```js\nvar csv = require('parse-csv');\nvar parser = new csv.Parser();\n```\n\n### [.parse](lib/parser.js#L72)\n\nParse CSV or tab-delimited string into a data-grid formatted JavaScript object.\n\n**Params**\n\n* `str` **{String}**\n* `options` **{Object}**\n* `returns` **{Object}**\n\n**Example**\n\n```js\nvar parser = new Parser();\n\nvar str = `\nid,fruit,vegetable\n1,apple,carrot\n2,orange,corn\n3,banana,potato`;\n\nvar datagrid = parser.parse(str);\n\n// results in:\n// { data:\n//    [ [ '1', 'apple', 'carrot' ],\n//      [ '2', 'orange', 'corn' ],\n//      [ '3', 'banana', 'potato' ] ],\n//   header:\n//    { names: [ 'id', 'fruit', 'vegetable' ],\n//      types: [ '-1': 'string' ] } }\n```\n\n### [Renderer](lib/renderer.js#L22)\n\nCreate a new `Renderer` with the given `options`.\n\n**Params**\n\n* `options` **{Object}**\n\n**Example**\n\n```js\nvar csv = require('parse-csv');\nvar renderer = new csv.Renderer();\n```\n\n### Available renderers\n\nThe following render methods are available when the renderer is used directly. Or specify the renderer on `options.renderer` when using the main export function.\n\n* `.as`: Actionscript\n* `.asp`: ASP/VBScript\n* `.html`: HTML\n* `.json`: JSON - Properties\n* `.jsonArrayCols`: JSON - Column Arrays\n* `.jsonArrayRows`: JSON - Row Arrays\n* `.jsonDict`: JSON - Dictionary\n* `.mysql`: MySQL\n* `.php`: PHP\n* `.python`: Python - Dict\n* `.ruby`: Ruby\n* `.xmlProperties`: XML - Properties\n* `.xml`: XML - Nodes\n* `.xmlIllustrator`: XML - Illustrator\n\n**Example**\n\nTo render CSV as HTML:\n\n```js\nvar csv = require('parse-csv');\nvar renderer = new csv.Renderer();\n\nvar str = `\nid,fruit,vegetable\n1,apple,carrot\n2,orange,corn\n3,banana,potato`;\n\nvar html = renderer.html(str, {headers: {included: true}});\nconsole.log(html);\n```\n\nResults in:\n\n```html\n<table>\n  <thead>\n    <tr>\n      <th class=\"id-cell\">id</th>\n      <th class=\"fruit-cell\">fruit</th>\n      <th class=\"vegetable-cell\">vegetable</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr class=\"firstRow\">\n      <td class=\"id-cell\">1</td>\n      <td class=\"fruit-cell\">apple</td>\n      <td class=\"vegetable-cell\">carrot</td>\n    </tr>\n    <tr>\n      <td class=\"id-cell\">2</td>\n      <td class=\"fruit-cell\">orange</td>\n      <td class=\"vegetable-cell\">corn</td>\n    </tr>\n    <tr class=\"lastRow\">\n      <td class=\"id-cell\">3</td>\n      <td class=\"fruit-cell\">banana</td>\n      <td class=\"vegetable-cell\">potato</td>\n    </tr>\n  </tbody>\n</table>\n```\n\n## Options\n\n### Parser options\n\nAvailable parser options and the actual defaults used.\n\n```js\n{\n  headers: {\n    included: false,\n    downcase: true,\n    upcase: true\n  },\n  delimiter: 'tab',\n  decimalSign: 'comma'\n}\n```\n\n### Renderer options\n\nAvailable renderer options and the actual defaults used.\n\n```js\n{\n  headers: {\n    included: true,\n    downcase: true,\n    upcase: true\n  },\n\n  delimiter: 'tab',\n  decimalSign: 'comma',\n  outputDataType: 'json',\n  columnDelimiter: \"\\t\",\n  rowDelimiter: '\\n',\n\n  inputHeader: {},\n  outputHeader: {},\n  dataSelect: {},\n\n  outputText: '',\n\n  newline: '\\n',\n  indent: '  ',\n\n  commentLine: '//',\n  commentLineEnd: '',\n  tableName: 'converter',\n\n  useUnderscores: true,\n  includeWhiteSpace: true,\n  useTabsForIndent: false\n}\n```\n\n## Related projects\n\nYou might also be interested in these projects:\n\n* [gulp-convert](https://www.npmjs.com/package/gulp-convert): Gulp plugin to convert to or from JSON, YAML, XML, PLIST or CSV. | [homepage](https://github.com/assemble/gulp-convert)\n* [parser-csv](https://www.npmjs.com/package/parser-csv): CSV parser, compatible with [parser-cache]. | [homepage](https://github.com/jonschlinkert/parser-csv)\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/parse-csv/issues/new).\n\n## Building docs\n\nGenerate readme and API documentation with [verb](https://github.com/verbose/verb):\n\n```sh\n$ npm install verb && npm run docs\n```\n\nOr, if [verb](https://github.com/verbose/verb) is installed globally:\n\n```sh\n$ verb\n```\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm install -d && npm test\n```\n\n## Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## License\n\nCopyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT license](https://github.com/jonschlinkert/parse-csv/blob/master/LICENSE).\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 09, 2016._","_attachments":{},"homepage":"https://github.com/jonschlinkert/parse-csv","bugs":{"url":"https://github.com/jonschlinkert/parse-csv/issues"},"license":"MIT"}