Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maddeveloper/lite-csv-parser
A very light csv parser using promises with no dependencies
https://github.com/maddeveloper/lite-csv-parser
Last synced: 7 days ago
JSON representation
A very light csv parser using promises with no dependencies
- Host: GitHub
- URL: https://github.com/maddeveloper/lite-csv-parser
- Owner: MadDeveloper
- License: mit
- Created: 2019-10-14T10:27:40.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T07:59:32.000Z (almost 2 years ago)
- Last Synced: 2024-11-08T20:19:18.427Z (2 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/lite-csv-parser
- Size: 2.3 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lite-csv-parser
`lite-csv-parser` is a **very light** csv parser using promises (**< 700B**, **< 450B** gzipped), with no dependencies.
As the package is using the UMD format, it can be used in any environment (Node, browser, ...).
The environment must support `Promise` (or can include a polyfill).The package does not currently support stream parsing.
## API
```js
parseCSV(input: String, options: Object): Promise
```## Options
| Name | Type | Default value | Description |
| ----------- | ------- | ------------- | -------------------------------------------------- |
| separator | string | , | Values separator |
| withHeaders | boolean | true | If the first line of the input defines the headers |## Usage
```js
import parseCSV from "lite-csv-parser"
// or
const parseCSV = require("lite-csv-parser")
// or (only browser)window.parseCSV // or just parseCSV
```
## Examples
```js
import parseCSV from "lite-csv-parser"const input = `some csv data`
parseCSV(input).then(console.log) // [{"id": 1, title: "first item"}, {"id": 2, title: "second item"}, ...]
parseCSV(input, { withHeaders: false }).then(console.log) // [[1, "first item"], [2, "second item"]]
parseCSV(input, { separator: ";" })
```