-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmultiblock.py
57 lines (54 loc) · 2.08 KB
/
multiblock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from readDayRecord import *
import readBlock
import sys
import time
BlockFileNameGroup_WithoutFileType = sys.argv[1:]
BlockFileGroup = []
StockIDGroup = []
milestonegroup = []
for i in BlockFileNameGroup_WithoutFileType:
if len(i) == 6 and i.isdigit():
#if it is all digi and six number len
StockIDGroup.append(i)
else:
if len(i) == 8 and i.isdigit():
#it is milestone.
milestonegroup.append(i)
else:
BlockFileGroup.append(i+'.blk')
milestonegroup_sorted = sorted(milestonegroup, key = lambda x: int(x))
today = time.localtime()
today_instring = str(today.tm_year*10000 + today.tm_mon*100 + today.tm_mday)
milestonegroup_sorted.append(today_instring)
total = len(milestonegroup_sorted)
if total == 1:
print "you have to input start time like 20110718"
exit()
period_group = []
#first is start and today
period_group.append([milestonegroup_sorted[0], milestonegroup_sorted[-1]])
if total <> 2:
i = 0
while i < (total -1):
period_group.append([milestonegroup_sorted[i], milestonegroup_sorted[i+1]])
i = i + 1
merged_result = []
for i in period_group:
startime = int(i[0])
endtime = int(i[1])
BlockCompareTable = readBlock.GetBlockSortTable(startime, endtime, BlockFileGroup)
StockIDCompareTable = []
for i in StockIDGroup:
tmp = [i, Percentage_byStockID(startime, endtime, i)]
StockIDCompareTable.append(tmp)
sortedTable = GetSortedTable(BlockCompareTable + StockIDCompareTable)
BlockGroupName = "MultiBlock"
outfileName_HTML = str(startime) + '_'+ str(endtime) + '_' + BlockGroupName + '.html'
outfileName_TEXT = str(startime) + '_'+ str(endtime) + '_' + BlockGroupName + '.txt'
merged_result.append([sortedTable, str(startime) + '_' + str(endtime)])
outfileText = open(outfileName_TEXT, 'w')
outfileText.write(OutputText(sortedTable, str(startime) + "->" + str(endtime)))
outfileText.close()
outfileText = open('allinone' + today_instring + '.txt', 'w')
outfileText.write(PaddingListTable2Text(MergeMultiTable(merged_result)))
outfileText.close()