# Getting Started

## Installation

```bash
yarn add @bottlenose/rxfs
```

Or...

```bash
npm i --save @bottelnose/rxfs
```

## Read file content into an Observable

```javascript
import path from 'path';
import {fromFile} from 'rxfs';

const csvContent = fromFile({
  filePath: path.resolve(__dirname, './my-csv.csv'),
});
csvContent$.subscribe(console.log);
// "name","scariness"
// "Blackbeard",10
// "Morgan",9
// "Sparrow",2
// "Crunch",1
```

## Write Observable content into a file (overwriting its contents)

```javascript
import path from 'path';
import {of} from 'rxjs';
import {writeFile} from 'rxfs';

const data = [
  '"animal","coolness"\n',
  '"dolphin",10\n',
  '"algae",1\n',
  '"mermaid",6\n',
  '"octopus",9\n',
  '"narwhale",8\n',
];

const writeStream$ = of(...data).pipe(
  writeFile({filePath: path.resolve(__dirname, './output.csv')})
);
// write the input observable to the file
writeStream$.subscribe(console.log);
```

## Append Observable content to a file

```javascript
import path from 'path';
import {of} from 'rxjs';
import {appendFile} from 'rxfs';

const moreData = [
  '"barnacle",3\n',
  '"seagull",2\n',
  '"clownfish",4\n',
];

const writeStream$ = of(...moreData).pipe(
  appendFile({filePath: path.resolve(__dirname, './output.csv')})
);
// append the input observable to the file
writeStream$.subscribe(console.log);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brianbuccaneer.gitbook.io/bottlenose/v0.7.0/sources-and-sinks/rxfs/getting_started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
