> For the complete documentation index, see [llms.txt](https://danfo.jsdata.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://danfo.jsdata.org/api-reference/general-functions/danfo.streamjson.md).

# danfo.streamJSON

danfo.**streamJSON**(filePath, callback, options)

| Parameters | Type     | Description                                                                                                                                                           |
| ---------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filePath   | string   | URL or local file path to CSV file.                                                                                                                                   |
| callback   | Function | Callback function to be called once the specifed rows are parsed into DataFrame.                                                                                      |
| options    | object   | Optional configuration object. We use the `request` library for reading remote json files, Hence all `request` parameters such as `method`, `headers`, are supported. |

The **streamJSON** function streams a JSON file from a local or remote location in chunks. Each intermediate chunk is passed as a DataFrame to the callback function.

## **Stream JSON file from local path**

{% tabs %}
{% tab title="Node" %}

```javascript
const dfd = require("danfojs-node")
const path = require("path")

const filePath = path.join(process.cwd(), "raw_data", "book_small.json");

dfd.streamJSON(filePath, (df) => {
    if (df) {
        // Do any processing here
        df.print();
    }
});
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Output" %}

```
//Showing the last rows 
...

╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║            │ book_id           │ title             │ image_url         │ authors           ║
╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 10         │ 32848471          │ Egomaniac         │ https://images.…  │ Vi Keeland        ║
╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝

╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║            │ book_id           │ title             │ image_url         │ authors           ║
╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 11         │ 33288638          │ Wait for It       │ https://s.gr-as…  │ Mariana Zapata    ║
╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝
```

{% endtab %}
{% endtabs %}

## **Stream JSON file from remote path**

{% tabs %}
{% tab title="Node" %}

```javascript
const dfd = require("danfojs-node")
const path = require("path")

const remoteFile = "https://raw.githubusercontent.com/opensource9ja/danfojs/dev/danfojs-node/tests/samples/book.json"

const callback = (df) => {
    //Perform any processing here
    if (df) {
        df.print();
    }
}

dfd.streamJSON(remoteFile, callback, { header: true })
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Output" %}

```
//Showing a few rows 
...

╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║            │ book_id           │ title             │ image_url         │ authors           ║
╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 10         │ 32848471          │ Egomaniac         │ https://images.…  │ Vi Keeland        ║
╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝

╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║            │ book_id           │ title             │ image_url         │ authors           ║
╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 11         │ 33288638          │ Wait for It       │ https://s.gr-as…  │ Mariana Zapata    ║
╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://danfo.jsdata.org/api-reference/general-functions/danfo.streamjson.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
