forked from CoreyMSchafer/code_snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_gen.py
More file actions
35 lines (24 loc) · 732 Bytes
/
data_gen.py
File metadata and controls
35 lines (24 loc) · 732 Bytes
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
import csv
import random
import time
x_value = 0
total_1 = 1000
total_2 = 1000
fieldnames = ["x_value", "total_1", "total_2"]
with open('data.csv', 'w') as csv_file:
csv_writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
csv_writer.writeheader()
while True:
with open('data.csv', 'a') as csv_file:
csv_writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
info = {
"x_value": x_value,
"total_1": total_1,
"total_2": total_2
}
csv_writer.writerow(info)
print(x_value, total_1, total_2)
x_value += 1
total_1 = total_1 + random.randint(-6, 8)
total_2 = total_2 + random.randint(-5, 6)
time.sleep(1)