I have a code which generates QR codes from a csv file:

#Importar base de dades
pathFile = ('E:\Usuarios\Daniel\Documents\APNAE\QR\Llistat_socis_alta.csv')
socisAPNAE = pd.read_csv(pathFile, delimiter = ';', encoding='ISO-8859-1')

#generar codi QR
for i in range(0,len(socisAPNAE.index)):    
    soci = socisAPNAE.iloc[i,1:6]
    nom = socisAPNAE.iloc[i,1]
    nom = nom.encode('latin-1')
    qr = QRCode(version=20, error_correction=ERROR_CORRECT_L)
    im = qr.make_image()

I would like to know how can I force the loop to rename the output file (test.jpeg, it is overwritten everytime the loop starts) with the string contained in the variable "nom". Can you help? Also, if you find a way to make the code nicer I'll be glad that you explain it to me. I'm just a beginer!
Thank you so much,


This question has already been answered. Start a new discussion instead.