I am looking for a way to print colored text in my html file but I can’t find so far.
What I do is to import data from a file, with the following columns, and I want to print in my html file in red each row where the column [‘Urgence’] is equal to ‘Urgent’.
How can I do this please ? Thank you.
My code is :
# Here we get the columns needed and we put them into a list
test = []
for index, row in df.iterrows():
x = row['Date'] + ' | ' + row['Description'] + ' | ' + row['Titre de la consigne'] + ' | ' + row['Prenom'] + ' | '
+ row['Urgence'] + ' | ' + row['Prenom'] + '\r\n'
test.append(x)
print(test)
Hi @BeginnerDash ,
I don’t think this is a Dash question. If you wanna know how to print colored content on web pages, the common way is to use CSS or markdown <span style="color:blue">text</span>
, as well \textcolor{tomato}{\LaTeX}.
Not sure this would work with my current code, I am not exactly printing a table, I thought maybe there is a function to print colored the text into the html file. I’ll try to see.
# Opening excel file
file = r"test2.xlsx"
try:
df = pd.read_excel(file)
except OSError:
print("Impossible to read :", file)
# Function to add a space between lines
def intersperse(lst, item):
result = [item] * (len(lst) * 2 - 1)
result[0::2] = lst
return result
# Printing lines
test = []
for index, row in df.iterrows():
x = row['Date'] + ' | ' + row['Description'] + ' | ' + row['Urgence'] + ' | ' + row['Prenom'] + ' | ' + row['Choix des equipements 1'] + ' | ' + row['Choix des equipements 2'] + ' | ' + row['Prenom'] + '\r\n'
test.append(x)
data = intersperse(test, html.Br())
Yes, I know. But considering your current learning progress, using dash-table would be a better choice.
Alternately, you need to learn callbacks first.