[LABI] tema04: added csv_writer.py
This commit is contained in:
parent
c1ff7ef8b9
commit
62c83db2e8
|
@ -0,0 +1,10 @@
|
|||
time;value
|
||||
1;41
|
||||
2;37
|
||||
3;3
|
||||
4;3
|
||||
5;37
|
||||
6;22
|
||||
7;91
|
||||
8;7
|
||||
9;25
|
|
|
@ -0,0 +1,16 @@
|
|||
import csv
|
||||
import random
|
||||
|
||||
|
||||
def main():
|
||||
fout = open("rand.csv", "w", newline='')
|
||||
writer = csv.DictWriter(fout, fieldnames=["time", "value"], delimiter=';')
|
||||
writer.writeheader()
|
||||
|
||||
for i in range(1, 10):
|
||||
writer.writerow({"time": i, "value": random.randint(1, 100)})
|
||||
|
||||
fout.close()
|
||||
|
||||
|
||||
main()
|
Loading…
Reference in New Issue