我正在用python开发一个脚本,它从日志文件中获取数据,我需要将每种类型的数据保存到相应的列中。我用正则表达式来获取数据
这是我的代码的一部分,我得到了这个结果:
#Getting data from log as list using regex
fecha = re.findall('\d{4}\-\d{2}\-\d{2}', str(listaValores))
hora = re.findall('\d{2}\:\d{2}\:\d{2}', str(listaValores))
#List of lists about data obtained
valoresFinales = [fecha, hora]
#Putting into .csv
with open("resultado.csv", "w") as f:
wr = csv.writer(f, delimiter=';')
wr.writerows(valoresFinales)
我想要什么
给
writerows
函数一个包含两个元素的列表,这样就得到了最后两行数据相反,你想给它一些类似于^{} :
相关问题 更多 >
编程相关推荐