About: The algorithm can produce n-amount of genereated codes with m-amount of length (200 and 6 by default respectively). If there is already a code.csv
file, it will add more codes to it as appropriately. It uses the secrets
library to get each code in order to guarantee the randomness when choosing each letter/digit.
Why: My sister asked me to generate about 100 unique codes to be used as a personal discount code for her product (https://academy.beactiveiseasy.com/), so I made this to satisfy her requirement and make it scalable for the future.
Possible Cons:
- If the input number of code to be generated < number of code in the .csv file, it will do nothing. This is to ensure that the generated codes do not get lost.
All arguments/changable variables:
path
: The path to the directory wherecode.csv
is savedlength
: the length of each codenum
: the number of code to be saved in thecode.csv
file