Skip to content

Commit

Permalink
Update generate_qr_code_images.py formatting to meet PEP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnuteegala authored Jan 12, 2024
1 parent 1a1af45 commit 86da03d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions generate_qr_code_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from PIL import Image

# Function to generate QR code from contact details


def generate_qr_code(data, output_file):
qr = qrcode.QRCode(
version=1,
Expand All @@ -18,19 +20,24 @@ def generate_qr_code(data, output_file):
img.save(output_file)

# Function to process Excel file and generate QR codes


def generate_qr_codes_from_excel(input_excel_file, output_folder):
try:
df = pd.read_excel(input_excel_file)
for index, row in df.iterrows():
contact_data = f"Name: {row['Name']}\nEmail: {row['Email']}\nPhone: {row['Phone']}"
output_file = f"{output_folder}/{row['Name']}_qr.png"
contact_data = f"Phone: +{row['Phone']}"
output_file = f"{output_folder}/+{row['Phone']}.png"
generate_qr_code(contact_data, output_file)
print(f"QR code for {row['Name']} generated and saved as {output_file}")
print(f"QR code for +{row['Phone']
} generated and saved as {output_file}")
except Exception as e:
print(f"Error processing the Excel file: {str(e)}")

if __name__ == "__main__":
input_excel_file = r"C:\Users\YourUsername\Documents\contact_data.xlsx" # Change this to your input Excel file
output_folder = r"C:\Users\YourUsername\Documents\QR_Codes" # Change this to your desired output folder
# Change this to your input Excel file
input_excel_file = r"C:\Users\YourUsername\Documents\contact_data.xlsx"
# Change this to your desired output folder
output_folder = r"C:\Users\YourUsername\Documents\QR_Codes"

generate_qr_codes_from_excel(input_excel_file, output_folder)
generate_qr_codes_from_excel(input_excel_file, output_folder)

0 comments on commit 86da03d

Please sign in to comment.