Python Forum
I need help using Python to generate usernames and passwords with excel documents
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help using Python to generate usernames and passwords with excel documents
#4
Hey guys, I'm incredibly new to Python and even more so to its modules.

I have an excel file (names.xsxl) with 33 names and info. I'm trying to create a script that generates a random username as well as a password for each user in the 'E' and 'F' column respectively. How would I do this with the help of my two functions?


I hope I'm making myself clear, if I'm not, don't hesitate to ask for a clarification. Here's my code so far:

  1 import random                                                                   
  2 import string                                                                                                                           
  8 from openpyxl import workbook                                                   
  9 from openpyxl import load_workbook                                              
 10 import xlrd                                                                     
 11                                                                                 
 12 wb = load_workbook('names.xlsx')  #reads the names.xlsx file                                              
 13 wb.save('names_mod.xlsx')         #saves it with the name: names_mod.xslx                                              
 14                                                                                 
 15 def randompassword(stringLength=8):   #creates a random password                                          
 16     lettersAndDigits = string.ascii_letters + string.digits                     
 17     return ''.join(random.choice(lettersAndDigits) for i in range(stringLength))
 18                                                                                 
 19 def username(stringLength=5):         #creates a random username                                     
 20     lettersAndDigits = string.ascii_letters + string.digits                     
 21     return ''.join(random.choice(lettersAndDigits) for i in range(stringLength))
Thankful for any help.
Reply


Messages In This Thread
How do I use my python functions to fill excel columns using openpyxl module? - by Jannejannesson - May-08-2019, 02:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with Python Script to generate SVG Dot Matrix Pattern for LED Light Guide iamrickm 2 771 Aug-25-2023, 06:07 PM
Last Post: iamrickm
  Word documents merging crewdk 1 860 Apr-03-2023, 06:32 AM
Last Post: buran
  best way to embed passwords into scripts mikey6785 3 2,284 Aug-31-2022, 08:22 AM
Last Post: DeaD_EyE
  Generate Python variables dynamically Pedroski55 5 2,895 Mar-04-2022, 10:13 PM
Last Post: deanhystad
  Encrypting Oracle Passwords / Python Library for That? bmccollum 1 2,597 Jun-11-2021, 07:59 PM
Last Post: Larz60+
  Сombine (Merge) word documents using python-docx Lancellot 1 11,574 May-12-2021, 11:07 AM
Last Post: toothedsword
  Copy documents to Teams using python SallySmith 0 2,389 Mar-23-2021, 04:27 AM
Last Post: SallySmith
Question Mouseover(Hover/Float) text in PDF documents ak52 1 2,574 Feb-24-2021, 06:13 PM
Last Post: nilamo
  Help with passwords program Vasilis 1 1,603 Jan-06-2021, 10:55 AM
Last Post: Larz60+
  Generate questions from excel to test my chatbot mcubac08 5 2,868 Sep-01-2020, 06:15 PM
Last Post: mcubac08

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020