Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nolleh/simple-csv-parser
transform csv string to javascript object
https://github.com/nolleh/simple-csv-parser
csv javascript nodejs npm-package typescript
Last synced: 26 days ago
JSON representation
transform csv string to javascript object
- Host: GitHub
- URL: https://github.com/nolleh/simple-csv-parser
- Owner: nolleh
- License: mit
- Created: 2023-04-15T06:55:23.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-10T05:39:19.000Z (over 1 year ago)
- Last Synced: 2024-12-20T10:41:36.193Z (about 2 months ago)
- Topics: csv, javascript, nodejs, npm-package, typescript
- Language: TypeScript
- Homepage:
- Size: 12.2 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Coverage Status](https://github.com/nolleh/simple-csv-parser/raw/gh-pages/badges/coverage-jest%20coverage.svg?raw=true)](https://nolleh.github.io/simple-csv-parser/badges/coverage-jest%20coverage.svg?raw=true)
[![npm version](https://badge.fury.io/js/@nolleh%2Fsimple-csv-parser.svg)](https://badge.fury.io/js/@nolleh%2Fsimple-csv-parser)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)## Overview
`simple-csv-parser`
for javascript / typescript.
marshal/serialize csv string to Object.## Usage
No need other dependency. super simple usage.
```typescript
class Message {
name: string;
message: string;
constructor(name: string, message: string) {
this.name = name;
this.message = message;
}
}const messages: Message[] = CsvParser.toObject(
`name,message\r\nnolleh,"hello, world"`
);// do something with messages...
const messages = CsvParser.toObject(
`name,message\r\nnolleh,"hello, world"\nnolleh,hello2`
);
console.log({ messages });
```result is
```bash
{
messages: [
{ name: 'nolleh', message: 'hello, world' },
{ name: 'nolleh', message: 'hello2' }
]
}
```if input string is malformed csv, then it return empty array.