我正在将制表符分隔的文本文件读入python列表,现在我想将列表项目放入excel文件中。我的文本文件的快照如下所示
BGIOSGA014473 0.955233 0.271947 3.5125704641 1.81252716688 Upregulated
BGIOSGA000577 0.219720 0.118096 1.86052025471 0.895706096568 Upregulated
BGIOSGA019391 0.959914 0.037380 25.67988229 4.68256668442 Upregulated
EPlOING00000022268 0.514413 0.701827 0.732962681687 -0.448188348529 Downregulated
BGIOSGA024514 0.481147 0.058495 8.22543807163 3.04009251617 Upregulated
i wanted it to be in this excel format
我试过的是这个
import xlwt
style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on')
wb = xlwt.Workbook(encoding="utf-8")
ws = wb.add_sheet('test')
with open("out.txt") as outfile:
for line in outfile:
line=line.strip().split("\t")
for i in range():
for i,e in enumerate(line):
ws.write(i,1,e)
wb.save('test.xls')
然而,我没有得到它。我想念如何更改行。任何人都可以帮忙
答案 0 :(得分:0)
我建议使用熊猫。代码就像
一样简单import pandas as pd
使用df = pd.DataFrame(dummy_for_data)
df.to_excel(path)
答案 1 :(得分:0)
您的问题:
Run
参数为ws.write()
(row, col, val)
需要参数这是一个工作样本。
range()