[LABI] tema04: added csv_writer.py
This commit is contained in:
parent
1cd588c313
commit
78f4c52302
|
@ -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