uaveiro-leci/1ano/2semestre/labi/tema04/src/csv_randomizer.py

17 lines
357 B
Python

import csv
import random
def main(args=None):
with open("../datafiles/example2.csv", "w") as f:
writer = csv.DictWriter(f, delimiter=",", fieldnames=["entry", "value"])
writer.writeheader()
for i in range(25):
writer.writerow({"entry": i, "value": random.randint(0, 100)})
if __name__ == '__main__':
main()