forked from UPRM-Moonbuggy-Telemetry/OnBoard-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsv_create.py
More file actions
30 lines (28 loc) · 1.13 KB
/
csv_create.py
File metadata and controls
30 lines (28 loc) · 1.13 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
import csv
import random as rnd
import time as t
timeArray = t.ctime().split(" ")
time = timeArray[3]
date = timeArray[0] + " " + timeArray[1] + " " + timeArray[2]
for i in range(10): # a for append newline = "" because by default it is \n
with open('test.csv', 'a', newline="") as csvFile:
writer = csv.writer(csvFile)
data = {
"id": rnd.randint(0, 100),
"strain_sensor_1": rnd.randint(0, 100),
"strain_sensor_2": rnd.randint(0, 100),
"strain_sensor_3": rnd.randint(0, 100),
"strain_sensor_4": rnd.randint(0, 100),
"vibration_sensor_1": rnd.randint(0, 100),
"vibration_sensor_2": rnd.randint(0, 100),
"vibration_sensor_3": rnd.randint(0, 100),
"vibration_sensor_4": rnd.randint(0, 100),
"vibration_sensor_5": rnd.randint(0, 100),
"battery_status": rnd.randint(0, 100),
"latitude": rnd.randint(0, 100),
"longitude": rnd.randint(0, 100),
"OBC_time": time,
"OBC_date": date
}
writer.writerow(data.values())
csvFile.close()