# tcsv

> CSV parser/stringifier.

Latest version **0.1.5** (published 2017-02-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install tcsv
pnpm add tcsv
yarn add tcsv
bun add tcsv
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2017-02-18 |
| First published | 2017-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nathan |
| Maintainers | nfd |

## Links

- npm: https://www.npmjs.com/package/tcsv
- Repository: https://github.com/nathan/tcsv
- Homepage: https://github.com/nathan/tcsv#readme
- Issues: https://github.com/nathan/tcsv/issues
- npm.io page: https://npm.io/package/tcsv

## Recent versions

- 0.1.5 (latest) — 2017-02-18
- 0.1.4 — 2017-02-18
- 0.1.3 — 2017-02-18
- 0.1.2 — 2017-02-18
- 0.1.1 — 2017-02-18
- 0.1.0 — 2017-02-18

## README

# tcsv

CSV parser/stringifier. Follows [RFC 4180](https://tools.ietf.org/html/rfc4180) in its output and is fairly permissive in its input.

# Install

```sh
$ npm i tcsv
```

# Use

```js
const tcsv = require('tcsv')
```

## parseRaw(string)

Separates a string into an row/column data (an array of row arrays).

```js
tcsv.parseRaw(`
abc,def,ghi
jkl,"m n o",pqr`)
/* [ [ 'abc', 'def', 'ghi' ], [ 'jkl', 'm n o', 'pqr' ] ] */
```

## parse(string, [fields = null, [asObject = false]])

Separates a string into structured data (an array of Map records).

```js
tcsv.parse(`
last,first,age
Smith,Alice,34
Doe,John,25`)
/* [
  Map { 'last' => 'Smith', 'first' => 'Alice', 'age' => '34' },
  Map { 'last' => 'Doe', 'first' => 'John', 'age' => '25' },
] */
```

Pass `fields` to return only those named columns. Pass `asObject` to use raw Object instances instead of Maps. If you are parsing user data and want Objects instead of Maps, make sure to pass a whitelist of fields.

```js
tcsv.parse(`
last,first,age
Smith,Alice,34
Doe,John,25`, ['last', 'age'], true)
/* [ { last: 'Smith', age: '34' }, { last: 'Doe', age: '25' } ] */
```

## stringifyRaw(array)

Serializes row/column data (an array of row arrays) to a string.

```js
tcsv.stringifyRaw([
  [ 'abc', 'def', 'ghi' ],
  [ 'jkl', 'm n o', 'pqr' ],
])
/* 'abc,def,ghi\r\njkl,m n o,pqr' */
```

## stringify(array)

Serializes structured data (an array of Map or Object records) to a string.

```js
tcsv.stringify([
  { last: 'Smith', first: 'Alice', age: '34' },
  { last: 'Doe', first: 'John', age: '25' },
])
/* 'last,first,age\r\nSmith,Alice,34\r\nDoe,John,25' */
```

---
_Source: https://npm.io/package/tcsv · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
