Program writing excel rfile with randomnized input - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Program writing excel rfile with randomnized input (/thread-1157.html) |
Program writing excel rfile with randomnized input - wepkes - Dec-08-2016 Hello everyone. I'm new to python. I have already tried to make some smal programs as excercise and that works fine for me but now i wanted to make something useful for me. I have different excel files (list with, names, forname, adress, phone number...). Each excel file has its own list. Now i want to make a program that can:
This is what i have for now: import xlrd import random import xlsxwriter #==> This I did for every workbook. workbook = xlrd.open_workbook("achternamen.xlsx") worksheet = workbook.sheet_by_index(0) total_rows = worksheet.nrows total_cols = worksheet.ncols tableAchternamen = list() recordAchternamen = list() for x in range(total_rows): for y in range(total_cols): recordAchternamen.append(worksheet.cell(x,y).value) tableAchternamen.append(recordAchternamen) recordAchternamen = [] x +=1 #==> This give me a result printed on Python SlachtofferAchternaam = print(random.choice(tableAchternamen)) SlachtofferVoornamen = print(random.choice(tableVoornamen)) SlachtofferTelefoonnummer = print(random.choice(tableTelefoonnummers)) SlachtofferAdressen = print(random.choice(tableAdressen)) resultaat = ( ['Achternaam', SlachtofferAchternaam], ['Voornaam', SlachtofferVoornamen], ['Telefoonnummer', SlachtofferTelefoonnummer], ['Adres',SlachtofferAdressen], ) #Start van de cellen die gebruikt worden row = 0 col = 0 for item, cost in (resultaat): worksheet.write(row, col, item) worksheet.write(row, col + 1, cost) row += 1 workbook.close()Please any help is welcome! ! ! RE: Program writing excel rfile with randomnized input - nilamo - Dec-08-2016 I'm not sure what the issue is, but I don't think your results have any values at all. print() doesn't return a value, so SlachtofferAchternaam = print(random.choice(tableAchternamen)) would mean SlachtofferAchternaam would always == None. Which is probably not what you want.Also, you don't really need x += 1 . The for loop will do that for you :p
|