# detect-csv

> Detect if a chunk of a string is a csv

Latest version **1.1.0** (published 2015-05-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install detect-csv
pnpm add detect-csv
yarn add detect-csv
bun add detect-csv
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2015-05-07 |
| First published | 2014-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Finn Pauls |
| Maintainers | finnpauls, karissa |
| Keywords | delimiter, csv, tsv |

## Links

- npm: https://www.npmjs.com/package/detect-csv
- Repository: https://github.com/finnp/detect-csv
- Issues: https://github.com/finnp/detect-csv/issues
- npm.io page: https://npm.io/package/detect-csv

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2015-05-07
- 1.0.1 — 2014-11-20
- 1.0.0 — 2014-11-20

## README

# detect-csv
Windows | Mac/Linux
------- | ---------
[![Windows Build status](http://img.shields.io/appveyor/ci/finnp/detect-csv.svg)](https://ci.appveyor.com/project/finnp/detect-csv/branch/master) | [![Build Status](https://travis-ci.org/finnp/detect-csv.svg?branch=master)](https://travis-ci.org/finnp/detect-csv)

Detect if a chunk in the beginning of a CSV (in the sense of character seperated values)
is valid and determine the delimiter character. Install with `npm install detect-csv`

Right now it only parses the first line and counts characters.
So the rest of the CSV might be invalid. Also I recommend checking for json/ndjson first,
since it's the more strict format.

```js
var detect = require('detect-csv')

var csv = detect('a,b,c\n1,2,3')

console.log(csv.delimiter)
console.log(csv.newline)
// prints ',' and '\n'

var isCsv = detect('notacsv')
console.log('This is ' + (isCsv ? '' : 'not') + ' a csv') 
// prints: This is not a csv
```

You add the following options as a second parameter:
* *delimiters* Delimiters to detect, defaults to `[',', ';', '\t', '|']`
* *newlines* Newline characters to detect, defaults to ['\n', '\r']

Delimiters and newlines don't work with multiple characters, e.g. `\r\n`.

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