Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haoliangyu/rx-from-csv
RxJS 5 operator to load csv file
https://github.com/haoliangyu/rx-from-csv
csv operator read rxjs
Last synced: 4 months ago
JSON representation
RxJS 5 operator to load csv file
- Host: GitHub
- URL: https://github.com/haoliangyu/rx-from-csv
- Owner: haoliangyu
- License: mit
- Created: 2017-05-14T04:59:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-18T12:15:39.000Z (almost 2 years ago)
- Last Synced: 2024-09-14T09:19:17.411Z (5 months ago)
- Topics: csv, operator, read, rxjs
- Language: TypeScript
- Size: 111 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# rx-from-csv
![build status](https://travis-ci.org/haoliangyu/rx-from-csv.svg?branch=master)
[![ReactiveX](http://reactivex.io/assets/Rx_Logo_S.png)](http://reactivex.io/)
[RxJS 5](http://reactivex.io/) operator to load [CSV](https://en.wikipedia.org/wiki/Comma-separated_values) file
Work in both JavaScript and TypeScript
## Installation
```
npm install rx-from-csv
```## Use
This library exposes a static `fromCSV` operator:
```
fromCSV(path: string, options?: object): Observable;
```The new `fromCSV` operator will load the CSV file from the give path and emit each row as an object, whose keys are column names and values are column values.
Parameters:
* **path**: csv file path
* **options**: optional configuration for the csv creation
* **delimiter**: a character to separate values. Default: `,`
* **noHeaderRow**: a boolean value to indicate whether there is a head row.
* **columns**: an array of column names. This is required if `noHeaderRow` is true.## Example
``` javascript
import { fromCSV } from 'rx-from-csv';/**
* For example, there is a data.csv with content
*
* id,name
* 1,"Mike",
* 2,"Tommy"
*/fromCSV('data.csv')
.subscribe((data) => {
console.log(data);
});/**
* It will output:
* { id: '1', name: 'Mike' }
* { id: '1', name: 'Tommy' }
*/
```## License
MIT