-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCV19_data.py
More file actions
104 lines (76 loc) · 2.2 KB
/
Copy pathCV19_data.py
File metadata and controls
104 lines (76 loc) · 2.2 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
#!/usr/bin/env python
# coding: utf-8
# In[36]:
import csv;
import os;
import random;
import string;
# In[7]:
# with open('People.csv', 'w', encoding='UTF8', newline='') as f:
# writer = csv.writer(f)
# # write the data
# for i in range(1, 1000001):
# x = random.randrange(0, 10000)
# y = random.randrange(0, 10000)
# data = [i, x, y]
# writer.writerow(data)
# print("done");
# with open('People_alt.csv', 'w', encoding='UTF8', newline='') as f:
# writer = csv.writer(f)
# # write the data
# for i in range(1, 101):
# x = random.randrange(0, 5000)
# y = random.randrange(0, 5000)
# data = [i, x, y]
# writer.writerow(data)
# print("done");
# In[39]:
# open the file in the write mode
f = open('People.csv', 'w', encoding='UTF8', newline='')
fs = open('S-Infected.csv', 'w', encoding='UTF8', newline='')
fl = open('L-Infected.csv', 'w', encoding='UTF8', newline='')
# create the csv writer
writeNorm = csv.writer(f)
writeInfectedS = csv.writer(fs)
writeInfectedL = csv.writer(fl)
# write a row to the csv file
for i in range(1, 1000001):
k = random.uniform(0,1)
x = random.randrange(0, 10000)
y = random.randrange(0, 10000)
data = [i, x, y]
if k<= 0.001:
writeInfectedS.writerow(data)
elif k<= 0.01:
writeInfectedL.writerow(data)
else:
writeNorm.writerow(data)
# close the file
f.close()
fs.close()
fl.close()
# In[33]:
# open the file in the write mode
f = open('People_alt.csv', 'w', encoding='UTF8', newline='')
fs = open('S-Infected_alt.csv', 'w', encoding='UTF8', newline='')
fl = open('L-Infected_alt.csv', 'w', encoding='UTF8', newline='')
# create the csv writer
writeNorm = csv.writer(f)
writeInfectedS = csv.writer(fs)
writeInfectedL = csv.writer(fl)
# write a row to the csv file
for i in range(1, 101):
k = random.uniform(0,1)
x = random.randrange(0, 5000)
y = random.randrange(0, 5000)
data = [i, x, y]
if k<0.05:
writeInfectedS.writerow(data)
elif k<0.3:
writeInfectedL.writerow(data)
else:
writeNorm.writerow(data)
# close the file
f.close()
fs.close()
fl.close()