May-06-2019, 05:49 PM
Hey guys, I need some serious help and guidance with creating a script. I realize I'm well over my head here but I still feel somehow I'm on the verge of "making something great". Worth noting is I'm incredibly new to python modules.
So, what I want is a python script that takes the existing content out of 1 excel file (called names.xsl) and then creates a new excel file but with an additional 2 columns, Username & Password. Now I have a function that generates a random 8 letter password. But I also need a function that generates a username based upon their names and room number(Which anybody is welcome to come with suggestions how to solve).
Layout of names.xsl:
A , B ,C , D
Name, socialsecuritynr, room, tel
Amy Anderson, 12345678, 636, 070xxx
etc etc (there are 33 names)
Layout of names_mod.xsl:
A , B , C , D , E , F
Name, socialsecuritynr, room, tel, Username, Password
Amy Anderson, 12345678, 636, 070xxx, amy636, randpa55
So, what I want is a python script that takes the existing content out of 1 excel file (called names.xsl) and then creates a new excel file but with an additional 2 columns, Username & Password. Now I have a function that generates a random 8 letter password. But I also need a function that generates a username based upon their names and room number(Which anybody is welcome to come with suggestions how to solve).
Layout of names.xsl:
A , B ,C , D
Name, socialsecuritynr, room, tel
Amy Anderson, 12345678, 636, 070xxx
etc etc (there are 33 names)
Layout of names_mod.xsl:
A , B , C , D , E , F
Name, socialsecuritynr, room, tel, Username, Password
Amy Anderson, 12345678, 636, 070xxx, amy636, randpa55
1 import pandas as pd 2 from pandas import ExcelWriter 3 from pandas import ExcelFile 4 import numpy as np 5 import xlsxwriter 6 7 import random 8 import string 9 10 def randompassword(stringLength=6): 11 lettersAndDigits = string.ascii_letters + string.digits 12 return ''.join(random.choice(lettersAndDigits) for i in range(stringLength)) 13 print (randompassword(8)) 14 15 df = pd.read_excel('names.xls', sheet_name='Sheet1') 16 17 workbook = xlsxwriter.Workbook('names_mod.xls') 18 worksheet = workbook.add_worksheet() 19 20 worksheet.write('E1', 'Username') 21 worksheet.write('F1', 'Password') 22 worksheet.write('F2-34',(randompassword(8)) 23 workbook.close() 24 25 df1 = pd.read_excel('names_mod.xls', sheet_name='Sheet1') 26 print(df1)I realize this is A LOT to ask and the whole sript is a complete mess at the moment.. but any help is muchly appreciated, I've been at this for a good week now and could really use some help. Please let me know if I'm breaking any forum rules or need to clarify anything. Thanks in advance.