Skip to content

Commit

Permalink
generateRandomCSV with parameters
Browse files Browse the repository at this point in the history
Il generatore ora accetta parametri da riga di comando per generare file CSV completi di nome e cognome, con un numero di righe variabile e un nome a scelta dell'utente (default: output.csv da 120 righe).
  • Loading branch information
gioxx committed Nov 28, 2024
1 parent 2b128c5 commit 4c5b741
Show file tree
Hide file tree
Showing 3 changed files with 287 additions and 11 deletions.
122 changes: 122 additions & 0 deletions tools/example_include-names.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
username,email,first_name,last_name
R4ddSbPyA8Nd,[email protected],Giulia,Conti
R4dd5ayA8Nd,[email protected],Milon,Fusk
vUp7apI5mOYw,[email protected],Giorgio,Ricci
UB2LlsBJ60p5,[email protected],Giorgio,Verdi
z745Z72uvacr,[email protected],Anna,Conti
wZmTHNm5PfXk,[email protected],Elena,Marini
oHZ1SQoye6lp,[email protected],Luigi,Ferrari
CuFQIrsPEoeP,[email protected],Luigi,Verdi
jYDP4qZmMrSA,[email protected],Luigi,Rossi
bZ2iU8MtwQu3,[email protected],Luca,Ferrari
shKLYnCwrIxM,[email protected],Elena,Ricci
r9Z5ABh8Jov9,[email protected],Mario,Esposito
eVqum5dRsMHj,[email protected],Marco,Neri
JAKD0ztv6aeP,[email protected],Marco,Rossi
jFOQFzSttjlX,[email protected],Giorgio,Verdi
fbeq8ODkkvWL,[email protected],Mario,Esposito
ZucBNo1XGNZS,[email protected],Anna,Neri
aG38DFEDFmdx,[email protected],Anna,Esposito
bKFSvD6qDJC0,[email protected],Elena,Verdi
btskuqlIypur,[email protected],Marco,Conti
sHzrfvE2JSjH,[email protected],Elena,Neri
POXcPryNo5aC,[email protected],Luca,Bianchi
RDOzaGnT5H3f,[email protected],Elena,Conti
VMHgbYTKmmVV,[email protected],Luca,Neri
cfxErhCb008r,[email protected],Giorgio,Marini
D3YfY6fi2ASo,[email protected],Francesca,Ricci
lm5RiNcopQ0J,[email protected],Mario,Esposito
89EKISBc7Q92,[email protected],Marco,Neri
cSCQZk2GzZSS,[email protected],Luca,Esposito
0L0wJ8wS7954,[email protected],Mario,Conti
JqguJykTgPMN,[email protected],Anna,Ricci
x5Do6WJIGPDa,[email protected],Marco,Conti
14BFGBeWyLZs,[email protected],Giorgio,Neri
JDSGSA3uxjNX,[email protected],Francesca,Rossi
dAAO0snPltLS,[email protected],Giulia,Ricci
qSv3NJibEjx2,[email protected],Marco,Verdi
pM982NRmzAYu,[email protected],Mario,Ricci
ZxUHJuugcEJt,[email protected],Mario,Esposito
fZ1QGTFb89bu,[email protected],Sofia,Verdi
ELfXZYLFe4dg,[email protected],Francesca,Bianchi
kjrWY069UkrB,[email protected],Marco,Gallo
vbNCWQy6aJAj,[email protected],Francesca,Rossi
0dMQUGCNt5HZ,[email protected],Elena,Esposito
HkB0br095Dvh,[email protected],Anna,Ricci
4NvCmirCtWPy,[email protected],Giulia,Conti
M0dzWpJPLW5w,[email protected],Giorgio,Gallo
1nzeLFdScW9i,[email protected],Mario,Rossi
4n7c0fdzBUGz,[email protected],Marco,Marini
8r3iOYOfRRPz,[email protected],Mario,Ferrari
Wsj8Sv9ldW3h,[email protected],Mario,Marini
BPhJWkCDbWQR,[email protected],Elena,Marini
wMh6u3fymLKZ,[email protected],Anna,Neri
EuXOo9PI9KYG,[email protected],Luca,Rossi
2dZZT8fGEIcQ,[email protected],Mario,Gallo
M5ORVxI4lVdU,[email protected],Marco,Ricci
7wUF35G0bpYj,[email protected],Giorgio,Gallo
HkRHcFcYo7Ms,[email protected],Giulia,Gallo
h9o2IWqBU7TX,[email protected],Giorgio,Gallo
yalCC3HGNki5,[email protected],Sofia,Ferrari
0i7DLpLprO77,[email protected],Luca,Ferrari
bWs4LADDdR8F,[email protected],Giulia,Verdi
ddFWuz0xPCX0,[email protected],Elena,Verdi
duBQlnnLPbyb,[email protected],Francesca,Rossi
jIiWmPwktyil,[email protected],Elena,Marini
rKMNHhpA9CpV,[email protected],Giorgio,Gallo
8R991OqtiZJV,[email protected],Marco,Rossi
hWxPwcA52B3c,[email protected],Elena,Bianchi
26S2Jwe96lnm,[email protected],Giulia,Conti
GAX75WeqTmsC,[email protected],Giulia,Esposito
9Ci4Y5r2J6xw,[email protected],Marco,Ricci
NvwTFH4D3NJ7,[email protected],Anna,Conti
jna9RBYkD1zF,[email protected],Elena,Rossi
N0TLHHSwgey7,[email protected],Luca,Neri
rJxXwJPIwqNN,[email protected],Giulia,Gallo
03F0KhV3rIFP,[email protected],Marco,Bianchi
Aze6JdsKWpv9,[email protected],Mario,Ricci
vmLcZlBa4tzj,[email protected],Elena,Neri
XdXiLy5OyTIW,[email protected],Luigi,Ferrari
kx3F8RLl9E04,[email protected],Giorgio,Neri
SILg4atinvNP,[email protected],Giulia,Esposito
5f5XKCTtwzGS,[email protected],Francesca,Verdi
beAcIsws6amh,[email protected],Mario,Esposito
2QXHndo6hqQ3,[email protected],Luca,Esposito
hAJsBFOhZYYp,[email protected],Luca,Esposito
vgrtRZ1kwH2O,[email protected],Elena,Ferrari
Tk06AnjXkewR,[email protected],Luigi,Rossi
hxehWCkA88dE,[email protected],Giorgio,Rossi
EeYgm5jfWy2g,[email protected],Elena,Marini
QAsitaDTHS34,[email protected],Luigi,Conti
VZfVFLwBIiPM,[email protected],Giulia,Ferrari
0NCiz7vBnxCl,[email protected],Sofia,Bianchi
IClbkvHzf2zk,[email protected],Francesca,Rossi
A4O8thQlBV99,[email protected],Giulia,Marini
7NRjbdiZk12E,[email protected],Sofia,Ricci
YOQeMZct87kj,[email protected],Giulia,Ferrari
LlDMWSQVAkdd,[email protected],Luigi,Ferrari
v5bYMf11WGRF,[email protected],Mario,Ferrari
Ek17Uk3wvcp0,[email protected],Mario,Neri
463IR3cOYa4G,[email protected],Mario,Esposito
xOUasKi3tRzd,[email protected],Mario,Marini
Se5PqYhsdoIu,[email protected],Luca,Ferrari
VXbTviADOUYP,[email protected],Sofia,Gallo
cg81yRbicKCv,[email protected],Luigi,Neri
IOjbkPRlaCNv,[email protected],Giulia,Neri
fsZUXYAHOddP,[email protected],Luigi,Bianchi
NCrnBZb9tPBe,[email protected],Elena,Marini
kcWmmXz2ttbt,[email protected],Giorgio,Verdi
hd09pdy2kDlj,[email protected],Mario,Neri
uhqFoXZ5eomg,[email protected],Anna,Neri
iQXg6zl2WkqA,[email protected],Luigi,Verdi
jRCQO2YGshsy,[email protected],Giulia,Ricci
fmCQrL7jj1aH,[email protected],Mario,Marini
tniIy2USig1t,[email protected],Sofia,Marini
7xxxVOw1D4ps,[email protected],Sofia,Gallo
FRlXbXmUuXvd,[email protected],Giulia,Esposito
VeV4mXHoDI1s,[email protected],Elena,Marini
VAcmsLPqIzdd,[email protected],Francesca,Verdi
4ZRhFy3TJJyG,[email protected],Anna,Marini
1jQjdv1hcFnU,[email protected],Luigi,Gallo
bf4WcbqPz5sR,[email protected],Mario,Rossi
4pPH3Cb8SfVS,[email protected],Anna,Marini
121 changes: 121 additions & 0 deletions tools/example_simple.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
username,email
YKobHZ7jEcAr,[email protected]
KAYdNcyZGVuD,[email protected]
0KEnZeRuuZF5,[email protected]
ahBW0ihUThbM,[email protected]
xk6ylvfhgKRP,[email protected]
e5yLTUct3lyT,[email protected]
OGOM3FKleCk7,[email protected]
Ndc73IWfxDbR,[email protected]
4zAKFa6F0dqT,[email protected]
wH2ebC1HdOc9,[email protected]
kfXXHsTOUCDm,[email protected]
GxXAFqKeZaPJ,[email protected]
wP8l7Q6ydexF,[email protected]
15mLmv3q7KCm,[email protected]
lfqQZFlQYJXg,[email protected]
ATkAeiBoJTFD,[email protected]
xebnfc60Dxru,[email protected]
7jhvT095wFtN,[email protected]
ikTUl3xDqsbM,[email protected]
JU0AVInY2moB,[email protected]
W4QvrnqcHf6y,[email protected]
dWm7VY62B5zw,[email protected]
ZMdTvGZWCnUO,[email protected]
x0D2XjThSjcL,[email protected]
sTw0OXX9dCsn,[email protected]
FmmqFFkvtDfq,[email protected]
xDhJXwOFQxfa,[email protected]
FUJcucFSB2Sl,[email protected]
0MkJapna01Mt,[email protected]
JXSysj94OrpJ,[email protected]
cT8G2m0P2YHL,[email protected]
8rcYBkbfffbA,[email protected]
3opNm1psgHx5,[email protected]
kI0IPUgOtwqO,[email protected]
NQsp4jddUZYG,[email protected]
MSh08aMZiSXZ,[email protected]
XizTJtLzv5yS,[email protected]
Y6l6GEjwKLSM,[email protected]
tgoK7B4u0tj8,[email protected]
a9sHZ3crRico,[email protected]
xBLa6r9VIqFC,[email protected]
uRBxrRTqVQdP,[email protected]
rRFXkmgRNYkg,[email protected]
dGEUJ0JN7qSi,[email protected]
Gb88uCQO5O0t,[email protected]
CUZFW4O8Pv4C,[email protected]
zJmSyFekBSko,[email protected]
wPfajTBBgnjs,[email protected]
NYIsbG859PN8,[email protected]
DbQGDmDhIpS4,[email protected]
3fBBrGjpcgBx,[email protected]
Phh1H4Iv8RAL,[email protected]
JxXqOznocLlk,[email protected]
5ppt6FAA40fQ,[email protected]
NoRgRYxDUAtV,[email protected]
qxqWRFedovts,[email protected]
h69SvU8KMQtz,[email protected]
0zGf4JiWknA1,[email protected]
t14bf8JSzkUR,[email protected]
utCF2ocNuNyf,[email protected]
mfmc67KACvWj,[email protected]
OAwiRrss0OsA,[email protected]
nj2hyGCOOxva,[email protected]
jZG2ABx4OIjt,[email protected]
suRo2B4N69XI,[email protected]
5qW3JrZn3C7b,[email protected]
RYp6CKeP9yFE,[email protected]
Sl6TUn4jZn6D,[email protected]
TMbigDcWXIeB,[email protected]
svEgF4q2LoLO,[email protected]
a96kzGTJFwtX,[email protected]
cU92GOi40slk,[email protected]
txmMTrwCJfpk,[email protected]
9FVd3gKIXn9O,[email protected]
qWNzeLCP34Wm,[email protected]
fqcHIJoSAhNP,[email protected]
KBYcLPBcb48O,[email protected]
ii0FJzo2UtkM,[email protected]
ksPQJxhngvLP,[email protected]
wD7keIY5nup4,[email protected]
q97PRUiU0W9e,[email protected]
n99kNNohMX5A,[email protected]
uaaDL347NvbC,[email protected]
F5CejCGdMwAA,[email protected]
CkLveZ7hmKLl,[email protected]
a5aMeRsmhJOQ,[email protected]
DTmCQXe75YvY,[email protected]
Kl90VpUxmT9N,[email protected]
gVXGdCLcdeTz,[email protected]
HssiwRMuN6VZ,[email protected]
a6WjYi95Fbk9,[email protected]
SLHdAQZ23p0c,[email protected]
7O78wVZbztjw,[email protected]
uqAMvc1Ofvn6,[email protected]
pabQsPo2Lyce,[email protected]
IdfT8XRyzJfP,[email protected]
BQLUKfGVYx4H,[email protected]
2wfchtW8Gmq3,[email protected]
4slv12rwLtqj,[email protected]
zMZ2CtdHycPD,[email protected]
UXRvcUPRsr2q,[email protected]
svsTiVBngHht,[email protected]
QOXHkvJ29W0l,[email protected]
jkwJoacjKSYb,[email protected]
xiOxWZGIkaPp,[email protected]
GCWhLyjSGurC,[email protected]
Iy4SpGPay9Sq,[email protected]
zZbTQntH4TVH,[email protected]
FcG9QtfcXLqX,[email protected]
xFW0LaZ3W3ub,[email protected]
WCgtkDWWhuWJ,[email protected]
TArUOWStIR7O,[email protected]
8Gjo7CL2gGwn,[email protected]
EPpqxVR0a4oi,[email protected]
Qw1jJe8Tsjlf,[email protected]
7iqSJO6d66PO,[email protected]
awXEH0Vn8cUa,[email protected]
2DkF2RO1p5r4,[email protected]
PhBKRWD5xES4,[email protected]
BjvEeLyfd66q,[email protected]
55 changes: 44 additions & 11 deletions tools/generateRandomCSV.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import csv
import random
import string
import argparse

# Funzione per generare un username casuale
def generate_username(length=12):
Expand All @@ -12,17 +13,49 @@ def generate_email(username, domain_list=['gnails.from', 'yau.com', 'hotmeil.con
domain = random.choice(domain_list)
return f"{username}@{domain}"

# Numero di righe da generare
num_rows = 120
# Funzione per generare un nome casuale
def generate_first_name():
first_names = ['Mario', 'Luigi', 'Giulia', 'Marco', 'Anna', 'Sofia', 'Giorgio', 'Elena', 'Luca', 'Francesca']
return random.choice(first_names)

# Creazione del file CSV
with open('output.csv', 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['username', 'email'])
# Funzione per generare un cognome casuale
def generate_last_name():
last_names = ['Rossi', 'Bianchi', 'Verdi', 'Neri', 'Gallo', 'Ferrari', 'Conti', 'Esposito', 'Ricci', 'Marini']
return random.choice(last_names)

for _ in range(num_rows):
username = generate_username()
email = generate_email(username)
writer.writerow([username, email])
# Funzione per generare il file CSV
def generate_csv(include_names, num_rows=120, output_file='output.csv'):
with open(output_file, 'w', newline='') as csvfile:
writer = csv.writer(csvfile)

print(f"File CSV generato: output.csv")
# Intestazione del CSV
if include_names:
writer.writerow(['username', 'email', 'first_name', 'last_name'])
else:
writer.writerow(['username', 'email'])

# Scrittura dei dati
for _ in range(num_rows):
username = generate_username()
email = generate_email(username)

if include_names:
first_name = generate_first_name()
last_name = generate_last_name()
writer.writerow([username, email, first_name, last_name])
else:
writer.writerow([username, email])

print(f"CSV file generated: {output_file}")

# Parser degli argomenti da riga di comando
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate a CSV file with random user data.')
parser.add_argument('--include-names', action='store_true', help='Include first and last names in the generated CSV')
parser.add_argument('--num-rows', type=int, default=120, help='Number of rows to generate (default: 120)')
parser.add_argument('--output-file', type=str, default='output.csv', help='Output CSV file name (default: output.csv)')

args = parser.parse_args()

# Generazione del file CSV
generate_csv(args.include_names, args.num_rows, args.output_file)

0 comments on commit 4c5b741

Please sign in to comment.