Hello, I need that when I write a row with writerow
in a file I put the text with a format or a color. And my other request could put color to a certain element of the list from python.
I share the code with you:
import csv
def leer():
m1 = open("archivo1.csv", "r")
m1_csv = csv.reader(m1)
var = ""
for i, x in enumerate(m1_csv):
lista0 = x[0:1]
lista1 = x[1:2]
header = str1 = ''.join(lista0)
header1 = header[9:13]
str1 = ''.join(lista1)
str1 = str1[1:]
str2 = str1[0:32]
listas = []
listas.append("The next header ")
listas.append(header1)
listas.append("")
if header1 == "goin":
listas.remove("")
listas.remove("goin")
listas.append("error")
listas.append(" the hash is outdate: " + str2)
if header1 == "omin":
listas.remove("")
listas.remove("omin")
listas.append("error")
listas.append(" the hash is outdate: " + str2)
if str2 == "074e3e3e82db7610dbeafd95c22d20a2":
listas.remove("")
listas.append(" is using for speaking")
listas.append(" example bla bla bla the packet")
listas.append(" Incident: you can get powers")
else:
s = "hola"
listo = ["OUTGOING HEADERS"]
listos = ["INCOMING HEADERS"]
m2_c = csv.writer(open("archivo2.csv", "a"), lineterminator='\n')
if i == 0:
m2_c.writerow(listo)
if i == 468:
m2_c.writerow(listos)
m2_c.writerow(listas)
m1.close()
Well, that's where the code is, so I do not have to format the text from python.