# Writing on the same line for streaming data

**URL:** <https://discuss.streamlit.io/t/writing-on-the-same-line-for-streaming-data/47696>\
**Category:** Using Streamlit\
**Created:** [July 22, 2023, 6:25am UTC](https://discuss.streamlit.io/t/writing-on-the-same-line-for-streaming-data/47696 "2023-07-22T06:25:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gtgoudar](https://avatars.discourse-cdn.com/v4/letter/g/4da419/32.png) [@gtgoudar](https://discuss.streamlit.io/u/gtgoudar)\
**Post date:** [July 22, 2023, 6:25am UTC](https://discuss.streamlit.io/t/writing-on-the-same-line-for-streaming-data/47696/1 "2023-07-22T06:25:50Z")

</div>

### Summary

How do I write an equivalent of the below in streamlit?

```auto
print(content, end="")

```

The equivalent in streamlit does not work

```auto
streamlit.write(content, end="")

---
Invalid arguments were passed to "st.write" function. Support for passing such unknown keywords arguments will be dropped in future. Invalid arguments were {end=""}

```

My use case is to write streaming data - data that is coming in chunks and I want to update it accordingly on the UI.

### Debug info

- Streamlit version: (get it with `$ streamlit version`) =\> Streamlit, version 1.25.0
- Python version: (get it with `$ python --version`) =\> Python 3.9.6
- Using Conda? PipEnv? PyEnv? Pex? =\> PipEnv
- OS version: 13.4 (22F66)
- Browser version:

### Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.  
Not sure what a requirements file is? Check out [this doc](https://docs.streamlit.io/streamlit-cloud/get-started/deploy-an-app/app-dependencies) and add a requirements file to your app.

### Links

- Link to your GitHub repo:
- Link to your deployed app:

### Additional information

NA

Thanks.

---

<div class="post-metadata">

**Author:** ![dataprofessor](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/dataprofessor/32/44163_2.png) [@dataprofessor](https://discuss.streamlit.io/u/dataprofessor)\
**Post date:** [July 22, 2023, 1:38pm UTC](https://discuss.streamlit.io/t/writing-on-the-same-line-for-streaming-data/47696/2 "2023-07-22T13:38:16Z")

</div>

Hi @gtgoudar

Can you iterate through your streaming data and use `st.write()` to write each iteration from within a placeholder created using `st.empty()`. In this way, it will display text as chunks as it is being generated.

An example of this in action is shown in a recent blog:

> **[How to build a Llama 2 chatbot](https://blog.streamlit.io/how-to-build-a-llama-2-chatbot/)**
>
> Experiment with this open-source LLM from Meta

The particular app code is (refer to lines 60-66):

> <https://github.com/dataprofessor/llama2/blob/master/streamlit_app.py>

---

<div class="post-metadata">

**Author:** ![gtgoudar](https://avatars.discourse-cdn.com/v4/letter/g/4da419/32.png) [@gtgoudar](https://discuss.streamlit.io/u/gtgoudar)\
**Post date:** [July 23, 2023, 1:29am UTC](https://discuss.streamlit.io/t/writing-on-the-same-line-for-streaming-data/47696/3 "2023-07-23T01:29:14Z")

</div>

Thank you kindly. This solved the problem for me.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [July 25, 2023, 1:29am UTC](https://discuss.streamlit.io/t/writing-on-the-same-line-for-streaming-data/47696/4 "2023-07-25T01:29:58Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
