rx-to-csv
RxJS 5 operator to write data into a CSV file
Work in both JavaScript and TypeScript
Installation
npm install rx-to-csv
Use
Import this library and it will add toCSV
operator to the rxjs Observable
class.
public toCSV(path: string, columns: Array<string>, options?: any): Observable
This operator will search values in its input by column names and write them into the target CSV file via a write file stream.
Parameters:
- path: csv file path
- columns: an array of column names
- options: optional configuration for the csv creation
- wrapText: a boolean value indicating whether to wrap text values with
"
. Default:true
- delimiter: a character to separate values. Default:
,
- wrapText: a boolean value indicating whether to wrap text values with
Example
Generate a CSV file from data flow:
;;let data =id: 1 name: 'Mike'id: 2 name: 'Tommy';Observable;
Download data from a PostgreSQL dadtabase and save it as a CSV file:
;;let db = 'connection string';db;
License
MIT