diff --git a/1ano/2semestre/labi/tema04/datafiles/rand.csv b/1ano/2semestre/labi/tema04/datafiles/rand.csv new file mode 100644 index 0000000..9aaeb18 --- /dev/null +++ b/1ano/2semestre/labi/tema04/datafiles/rand.csv @@ -0,0 +1,10 @@ +time;value +1;41 +2;37 +3;3 +4;3 +5;37 +6;22 +7;91 +8;7 +9;25 diff --git a/1ano/2semestre/labi/tema04/src/csv_writer.py b/1ano/2semestre/labi/tema04/src/csv_writer.py new file mode 100644 index 0000000..12743d1 --- /dev/null +++ b/1ano/2semestre/labi/tema04/src/csv_writer.py @@ -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()