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)