bmilleridentco bmilleridentco - 1 year ago 65
Python Question

Saving a list of UUID numbers to a .csv file in python

I am trying to create a .csv file of UUID numbers. I see how to make a single UUID number in python but can't get the correct syntax to make 50 numbers and save them to a .csv file. I've googled and found many ways to create .csv files and how to use For loop but none seem to pertain to this particular application. Thank you for any help.

Answer Source

Just combine a csv writer with an uuid generator

import csv
import uuid
with open('uuids.csv', 'w') as csvfile:
    uuidwriter = csv.writer(csvfile)
    for i in range(50):