Comparing version 1.0.2 to 1.0.3
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-dsv/ Version 1.0.2. Copyright 2016 Mike Bostock. | ||
// https://d3js.org/d3-dsv/ Version 1.0.3. Copyright 2016 Mike Bostock. | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-dsv/ Version 1.0.2. Copyright 2016 Mike Bostock. | ||
// https://d3js.org/d3-dsv/ Version 1.0.3. Copyright 2016 Mike Bostock. | ||
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(r.d3=r.d3||{})}(this,function(r){"use strict";function n(r){return new Function("d","return {"+r.map(function(r,n){return JSON.stringify(r)+": d["+n+"]"}).join(",")+"}")}function t(r,t){var e=n(r);return function(n,o){return t(e(n),o,r)}}function e(r){var n=Object.create(null),t=[];return r.forEach(function(r){for(var e in r)e in n||t.push(n[e]=e)}),t}function o(r){function o(r,e){var o,a,i=u(r,function(r,u){return o?o(r,u-1):(a=r,void(o=e?t(r,e):n(r)))});return i.columns=a,i}function u(r,n){function t(){if(c>=f)return a;if(o)return o=!1,u;var n,t=c;if(34===r.charCodeAt(t)){for(var e=t;e++<f;)if(34===r.charCodeAt(e)){if(34!==r.charCodeAt(e+1))break;++e}return c=e+2,n=r.charCodeAt(e+1),13===n?(o=!0,10===r.charCodeAt(e+2)&&++c):10===n&&(o=!0),r.slice(t+1,e).replace(/""/g,'"')}for(;c<f;){var i=1;if(n=r.charCodeAt(c++),10===n)o=!0;else if(13===n)o=!0,10===r.charCodeAt(c)&&(++c,++i);else if(n!==p)continue;return r.slice(t,c-i)}return r.slice(t)}for(var e,o,u={},a={},i=[],f=r.length,c=0,s=0;(e=t())!==a;){for(var d=[];e!==u&&e!==a;)d.push(e),e=t();n&&null==(d=n(d,s++))||i.push(d)}return i}function a(n,t){return null==t&&(t=e(n)),[t.map(c).join(r)].concat(n.map(function(n){return t.map(function(r){return c(n[r])}).join(r)})).join("\n")}function i(r){return r.map(f).join("\n")}function f(n){return n.map(c).join(r)}function c(r){return null==r?"":s.test(r+="")?'"'+r.replace(/\"/g,'""')+'"':r}var s=new RegExp('["'+r+"\n]"),p=r.charCodeAt(0);return{parse:o,parseRows:u,format:a,formatRows:i}}var u=o(","),a=u.parse,i=u.parseRows,f=u.format,c=u.formatRows,s=o("\t"),p=s.parse,d=s.parseRows,v=s.format,l=s.formatRows;r.dsvFormat=o,r.csvParse=a,r.csvParseRows=i,r.csvFormat=f,r.csvFormatRows=c,r.tsvParse=p,r.tsvParseRows=d,r.tsvFormat=v,r.tsvFormatRows=l,Object.defineProperty(r,"__esModule",{value:!0})}); |
{ | ||
"name": "d3-dsv", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A parser and formatter for delimiter-separated values, such as CSV and TSV", | ||
@@ -22,6 +22,11 @@ "keywords": [ | ||
"bin": { | ||
"csv2tsv": "./bin/csv2tsv", | ||
"csv2json": "./bin/csv2json", | ||
"tsv2csv": "./bin/tsv2csv", | ||
"tsv2json": "./bin/tsv2json" | ||
"csv2json": "bin/dsv2json", | ||
"csv2tsv": "bin/dsv2dsv", | ||
"dsv2dsv": "bin/dsv2dsv", | ||
"dsv2json": "bin/dsv2json", | ||
"json2csv": "bin/json2dsv", | ||
"json2dsv": "bin/json2dsv", | ||
"json2tsv": "bin/json2dsv", | ||
"tsv2csv": "bin/dsv2dsv", | ||
"tsv2json": "bin/dsv2json" | ||
}, | ||
@@ -28,0 +33,0 @@ "repository": { |
176
README.md
@@ -216,18 +216,172 @@ # d3-dsv | ||
This module comes with a few binaries to convert DSV files: | ||
### dsv2dsv | ||
* csv2json [<>](https://github.com/d3/d3-dsv/blob/master/bin/csv2json "Source") | ||
* csv2tsv [<>](https://github.com/d3/d3-dsv/blob/master/bin/csv2tsv "Source") | ||
* tsv2csv [<>](https://github.com/d3/d3-dsv/blob/master/bin/tsv2csv "Source") | ||
* tsv2json [<>](https://github.com/d3/d3-dsv/blob/master/bin/tsv2json "Source") | ||
<a name="dsv2dsv" href="#dsv2dsv">#</a> <b>dsv2dsv</b> [<i>options…</i>] [<i>file</i>] | ||
These programs either take a single file as an argument or read from stdin, and write to stdout. For example, these statements are all equivalent: | ||
Converts the specified DSV input *file* to DSV (typically with a different delimiter or encoding). If *file* is not specified, defaults to reading from stdin. For example, to convert to CSV to TSV: | ||
``` | ||
csv2json file.csv > file.json | ||
csv2json < file.csv > file.json | ||
csv2json - < file.csv > file.json | ||
cat file.csv | csv2json - > file.json | ||
csv2tsv < example.csv > example.tsv | ||
``` | ||
Use --help for more. | ||
To convert windows-1252 CSV to utf-8 CSV: | ||
``` | ||
dsv2dsv --input-encoding windows-1252 < latin1.csv > utf8.csv | ||
``` | ||
<a name="dsv2dsv_help" href="dsv2dsv_help">#</a> dsv2dsv <b>-h</b> | ||
<br><a href="dsv2dsv_help">#</a> dsv2dsv <b>--help</b> | ||
Output usage information. | ||
<a name="dsv2dsv_version" href="dsv2dsv_version">#</a> dsv2dsv <b>-V</b> | ||
<br><a href="dsv2dsv_version">#</a> dsv2dsv <b>--version</b> | ||
Output the version number. | ||
<a name="dsv2dsv_out" href="dsv2dsv_out">#</a> dsv2dsv <b>-o</b> <i>file</i> | ||
<br><a href="dsv2dsv_out">#</a> dsv2dsv <b>--out</b> <i>file</i> | ||
Specify the output file name. Defaults to “-” for stdout. | ||
<a name="dsv2dsv_input_delimiter" href="dsv2dsv_input_delimiter">#</a> dsv2dsv <b>-r</b> <i>delimiter</i> | ||
<br><a href="dsv2dsv_input_delimiter">#</a> dsv2dsv <b>--input-delimiter</b> <i>delimiter</i> | ||
Specify the input delimiter character. Defaults to “,” for reading CSV. (You can enter a tab on the command line by typing ⌃V.) | ||
<a name="dsv2dsv_input_encoding" href="dsv2dsv_input_encoding">#</a> dsv2dsv <b>--input-encoding</b> <i>encoding</i> | ||
Specify the input character encoding. Defaults to “utf8”. | ||
<a name="dsv2dsv_output_delimiter" href="dsv2dsv_output_delimiter">#</a> dsv2dsv <b>-w</b> <i>delimiter</i> | ||
<br><a href="dsv2dsv_output_delimiter">#</a> dsv2dsv <b>--output-delimiter</b> <i>delimiter</i> | ||
Specify the output delimiter character. Defaults to “,” for writing CSV. (You can enter a tab on the command line by typing ⌃V.) | ||
<a name="dsv2dsv_output_encoding" href="dsv2dsv_output_encoding">#</a> dsv2dsv <b>--output-encoding</b> <i>encoding</i> | ||
Specify the output character encoding. Defaults to “utf8”. | ||
<a name="csv2tsv" href="#csv2tsv">#</a> <b>csv2tsv</b> [<i>options…</i>] [<i>file</i>] | ||
Equivalent to [dsv2dsv](#dsv2dsv), but the [output delimiter](#dsv2dsv_output_delimiter) defaults to the tab character (\t). | ||
<a name="tsv2csv" href="#tsv2csv">#</a> <b>tsv2csv</b> [<i>options…</i>] [<i>file</i>] | ||
Equivalent to [dsv2dsv](#dsv2dsv), but the [input delimiter](#dsv2dsv_output_delimiter) defaults to the tab character (\t). | ||
### dsv2json | ||
<a name="dsv2json" href="#dsv2json">#</a> <b>dsv2json</b> [<i>options…</i>] [<i>file</i>] | ||
Converts the specified DSV input *file* to JSON. If *file* is not specified, defaults to reading from stdin. For example, to convert to CSV to JSON: | ||
``` | ||
csv2json < example.csv > example.json | ||
``` | ||
Or to convert CSV to a newline-delimited JSON stream: | ||
``` | ||
csv2json -n < example.csv > example.ndjson | ||
``` | ||
<a name="dsv2json_help" href="dsv2json_help">#</a> dsv2json <b>-h</b> | ||
<br><a href="dsv2json_help">#</a> dsv2json <b>--help</b> | ||
Output usage information. | ||
<a name="dsv2json_version" href="dsv2json_version">#</a> dsv2json <b>-V</b> | ||
<br><a href="dsv2json_version">#</a> dsv2json <b>--version</b> | ||
Output the version number. | ||
<a name="dsv2json_out" href="dsv2json_out">#</a> dsv2json <b>-o</b> <i>file</i> | ||
<br><a href="dsv2json_out">#</a> dsv2json <b>--out</b> <i>file</i> | ||
Specify the output file name. Defaults to “-” for stdout. | ||
<a name="dsv2json_input_delimiter" href="dsv2json_input_delimiter">#</a> dsv2json <b>-r</b> <i>delimiter</i> | ||
<br><a href="dsv2json_input_delimiter">#</a> dsv2json <b>--input-delimiter</b> <i>delimiter</i> | ||
Specify the input delimiter character. Defaults to “,” for reading CSV. (You can enter a tab on the command line by typing ⌃V.) | ||
<a name="dsv2json_input_encoding" href="dsv2json_input_encoding">#</a> dsv2json <b>--input-encoding</b> <i>encoding</i> | ||
Specify the input character encoding. Defaults to “utf8”. | ||
<a name="dsv2json_output_encoding" href="dsv2json_output_encoding">#</a> dsv2json <b>-r</b> <i>encoding</i> | ||
<br><a href="dsv2json_output_encoding">#</a> dsv2json <b>--output-encoding</b> <i>encoding</i> | ||
Specify the output character encoding. Defaults to “utf8”. | ||
<a name="dsv2json_newline_delimited" href="dsv2json_newline_delimited">#</a> dsv2json <b>-n</b> | ||
<br><a href="dsv2json_newline_delimited">#</a> dsv2json <b>--newline-delimited</b> | ||
Output [newline-delimited JSON](https://github.com/mbostock/ndjson-cli) instead of a single JSON array. | ||
<a name="csv2json" href="#csv2json">#</a> <b>csv2json</b> [<i>options…</i>] [<i>file</i>] | ||
Equivalent to [dsv2json](#dsv2json). | ||
<a name="tsv2json" href="#csv2json">#</a> <b>tsv2json</b> [<i>options…</i>] [<i>file</i>] | ||
Equivalent to [dsv2json](#dsv2json), but the [input delimiter](#dsv2json_input_delimiter) defaults to the tab character (\t). | ||
### json2dsv | ||
<a name="json2dsv" href="#json2dsv">#</a> <b>json2dsv</b> [<i>options…</i>] [<i>file</i>] | ||
Converts the specified JSON input *file* to DSV. If *file* is not specified, defaults to reading from stdin. For example, to convert to JSON to CSV: | ||
``` | ||
json2csv < example.json > example.csv | ||
``` | ||
Or to convert a newline-delimited JSON stream to CSV: | ||
``` | ||
json2csv -n < example.ndjson > example.csv | ||
``` | ||
<a name="json2dsv_help" href="json2dsv_help">#</a> json2dsv <b>-h</b> | ||
<br><a href="json2dsv_help">#</a> json2dsv <b>--help</b> | ||
Output usage information. | ||
<a name="json2dsv_version" href="json2dsv_version">#</a> json2dsv <b>-V</b> | ||
<br><a href="json2dsv_version">#</a> json2dsv <b>--version</b> | ||
Output the version number. | ||
<a name="json2dsv_out" href="json2dsv_out">#</a> json2dsv <b>-o</b> <i>file</i> | ||
<br><a href="json2dsv_out">#</a> json2dsv <b>--out</b> <i>file</i> | ||
Specify the output file name. Defaults to “-” for stdout. | ||
<a name="json2dsv_input_encoding" href="json2dsv_input_encoding">#</a> json2dsv <b>--input-encoding</b> <i>encoding</i> | ||
Specify the input character encoding. Defaults to “utf8”. | ||
<a name="json2dsv_output_delimiter" href="json2dsv_output_delimiter">#</a> json2dsv <b>-w</b> <i>delimiter</i> | ||
<br><a href="json2dsv_output_delimiter">#</a> json2dsv <b>--output-delimiter</b> <i>delimiter</i> | ||
Specify the output delimiter character. Defaults to “,” for writing CSV. (You can enter a tab on the command line by typing ⌃V.) | ||
<a name="json2dsv_output_encoding" href="json2dsv_output_encoding">#</a> json2dsv <b>--output-encoding</b> <i>encoding</i> | ||
Specify the output character encoding. Defaults to “utf8”. | ||
<a name="json2dsv_newline_delimited" href="json2dsv_newline_delimited">#</a> json2dsv <b>-n</b> | ||
<br><a href="json2dsv_newline_delimited">#</a> json2dsv <b>--newline-delimited</b> | ||
Read [newline-delimited JSON](https://github.com/mbostock/ndjson-cli) instead of a single JSON array. | ||
<a name="csv2json" href="#csv2json">#</a> <b>csv2json</b> [<i>options…</i>] [<i>file</i>] | ||
Equivalent to [json2dsv](#json2dsv). | ||
<a name="tsv2json" href="#csv2json">#</a> <b>tsv2json</b> [<i>options…</i>] [<i>file</i>] | ||
Equivalent to [json2dsv](#json2dsv), but the [output delimiter](#json2dsv_output_delimiter) defaults to the tab character (\t). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37430
387
14