Demo entry 6635751

count

   

Submitted by anonymous on Aug 19, 2017 at 15:01
Language: Python. Code size: 608 Bytes.

#-*-coding:utf-8 -*-
import xlwt
file = xlwt.Workbook()                
table = file.add_sheet('sheet1')  
table.write(0,1,'a')
table.write(0,2,'t')
table.write(0,3,'g')
table.write(0,4,'c')
file_object = open('test.txt') 
file_context = file_object.read()
arr = file_context.split(':')
del arr[0]
i=1
for str in arr:
	table.write(i,0,i)
	table.write(i,1,str.count('a'))
	table.write(i,2,str.count('t'))
	table.write(i,3,str.count('g'))
	table.write(i,4,str.count('c'))
	i = i+1
table = file.add_sheet('sheet name',cell_overwrite_ok=True)
file.save('count.xls')     
file_object.close()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).