如何使用python将文本中的要素数据提取到excel

时间:2017-02-25 08:42:10

标签: python excel

最近,我得到了一些文本文件,我的任务是从这些文件中提取有意义的数据并将它们组织成excel。

需要提取文本中有意义的数据,如图所示:

enter image description here

最后将数据提取到excel表中,如下所示:

enter image description here

我的想法是读取这些文本文件并进行过滤,然后使用xlswriter包写入xlsx文件里面,但现在混淆了我是如何将这些文件过滤掉并拦截相应的数据写入相应的excel里面柱。我需要你的建议,非常感谢你。

import xlsxwriter
import os
'''
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('Expenses01.xlsx')
worksheet = workbook.add_worksheet()

# init excel worksheet
worksheet.write('A1','module_name')
worksheet.write('B1','Source IP Adress')
worksheet.write('C1','Source Port')
worksheet.write('D1','Target Zone')
worksheet.write('E1','Target IP Adrress')
worksheet.write('F1','Target Port')
worksheet.write('G1','Protocol')
worksheet.write('H1','Action')
worksheet.write('I1','Port Description')
'''

f=open("20161223030022_running.cfg",'rb')
ff=f.readlines()
for line in ff:
    what should i do in next step

0 个答案:

没有答案