Building Streamlit App within Snowflake.
Version of Streamlit Available -: 1.22
I am trying to display a report in a tabular format. The table contains Text and Number Fields.
The text columns can have carriange return, newline and can be quite lengthy.
I have tried various display option but not get the right text wrapping similar to what is available in excel for example.
I need to get to a point where the report in streamlit looks as a excel like word wrap format.
Thanks Sahir. I tried this out but unfortunately it doesn’t work for me.
import streamlit as st
import pandas as pd
import time
def get_dataset():
selected_columns = ["ID", "COL1", "COL2","COL3","COL4","COL5"]
data = {
"Column1": ["First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line First line\nSecond line ", "Data 1\nData 2", "Entry one\nEntry two", "Text A\nText B"],
"Column2": ["Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 Example 1\nExample 2 ", "Sample 1\nSample 2", "Info A\nInfo B", "Detail 1\nDetail 2"],
"Column3": ["Line one\nLine two", "Record 1\nRecord 2", "Note A\nNote B", "Item 1\nItem 2"],
"Column4": ["Value A\nValue B", "Number 1\nNumber 2", "Content A\nContent B", "Piece 1\nPiece 2"]
}
df = pd.DataFrame(data)
return df
dataset = get_dataset()
custom_css = """
<style>
.dataframe th, .dataframe td {
white-space: pre-wrap;
vertical-align: top;
font-size: 20px;
}
.dataframe .blank, .dataframe .nan {
color: #ccc;
}
</style>
"""
st.markdown(custom_css, unsafe_allow_html=True)
st.dataframe(dataset, width=None, height=None)
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.