-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDWDM_dataset_Extraction.py
More file actions
108 lines (91 loc) · 2.16 KB
/
DWDM_dataset_Extraction.py
File metadata and controls
108 lines (91 loc) · 2.16 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# create database
# database = dict()
# database['sid']=[10,20,30,40]
# database['sequence']=[['a','abc','ac','d'],['ad','c','bc','ae'],['ad','bc','df'],['a','abc','d']]
# database['timestamp']=[[0,1,2,3],[1,2,3,4],[1,3,5],[2,3,4]]
#
# database['10'] = [['a', 0], ['abc', 1], ['ac', 2], ['d', 3]]
# database['20'] = [['ad', 1], ['c', 2], ['bc', 3], ['ae', 4]]
# database['30'] = [['ad', 1], ['bc', 3], ['df', 5]]
# database['cd40'] = [['a', 2], ['abc', 3], ['d', 4]]
#
# # print database
#
# for i in database.keys():
# print(i, end=' ')
# for j in database[i]:
# print(j[0], end=' ')
# for j in database[i]:
# print(j[1], end=' ')
# print()
import random
# lower = 111; upper = 999
# random_float = random.uniform(lower, upper)
# print(random_float)
def Randlist(start, end, num):
res = []
for j in range(num):
val=(random.uniform(start, end))
# val=int(val)
res.append(val)
res.sort()
return res
text_file= open("sample.data","r")
lines= text_file.readlines()
# line1= lines[0]
undelted_lines= lines
print("\nInput :\n")
print(lines)
x = dict()
for i in range(len(lines)):
line1 = list(lines[i].split(" "))
# print(line1)
line1.pop()
length = int(line1[0])
# print(length)
line1.pop(0)
# x= dict()
# print(line1)
lst = []
for j in range(length):
sizeoflistoftime= int(line1[0])
# print(sizeoflistoftime)
line1.pop(0)
# print(line1)
listoftime=Randlist(0,1000,sizeoflistoftime)
for k in range(sizeoflistoftime):
line1.pop(0)
# print(listoftime)
lst.append(listoftime)
# print("The list is :")
# print(lst)
x[i]=lst
# print(x)
# print(undelted_lines)
x2= dict()
for i in range(len(undelted_lines)):
line1 = list(undelted_lines[i].split(" "))
# print(line1)
line1.pop()
length = int(line1[0])
# print(length)
line1.pop(0)
# print(line1)
listoftime=[]
for j in range(length):
sizeoflistoftime= int(line1[0])
# print(sizeoflistoftime)
line1.pop(0)
# print(line1)
temp=""
# listoftime=Randlist(0,1000,sizeoflistoftime)
for k in range(sizeoflistoftime):
temp=temp+line1[0]
line1.pop(0)
listoftime.append(temp)
# print(listoftime)
x2[i]=listoftime
print("\n\nTime stamp\n")
print(x)
print("\n\nSequence\n")
print(x2)