-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-GUIDs.py
43 lines (31 loc) · 978 Bytes
/
generate-GUIDs.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
# Generates one file with a bunch of GUIDs and a second file
# with a random subset of those GUIDs. It then optionally adds some new
# GUIDs to the end of the subset file.
# Parameters:
# 1: Number of GUIDs in the large file
# 2: Number of subset GUIDs in the small file
# 3: Number of additional GUIDs to add to the small file
# 4: The output file name
import sys,os,uuid,random
baseFileName=os.path.splitext(sys.argv[4])[0]
baseFileExtension=os.path.splitext(sys.argv[4])[1]
f = open(sys.argv[4], "w")
i = 1
while i <= int(sys.argv[1]) :
x=uuid.uuid4()
y=random.randint(1,1001)
f.write(str(x)+','+str(y)+'\n')
i += 1
f.close()
with open(sys.argv[4]) as f:
lines = random.sample(f.readlines(),int(sys.argv[2]))
f = open(baseFileName+'-subset'+baseFileExtension, "w")
for line in lines:
f.write(line)
i = 1
while i <= int(sys.argv[3]) :
x=uuid.uuid4()
y=random.randint(1,1001)
f.write(str(x)+','+str(y)+'\n')
i += 1
f.close()