Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xlrd
- from Drivers.accounts.models import Profile, User
- import random
- rb = xlrd.open_workbook('final_base.xlsx')
- sheet = rb.sheet_by_index(0)
- data = []
- for rownum in range(1, sheet.nrows):
- row = sheet.row_values(rownum)
- dataitem = []
- for c_el in row:
- dataitem.append(c_el)
- data.append(dataitem)
- for item in data:
- password = random.randint(10000, 99999)
- fullname = item[0].split(' ')
- try:
- user = User.objects.get(username=item[3])
- except:
- user = User.objects.create(username=item[3], first_name=fullname[0],
- last_name=fullname[1], password=password,
- email=item[3])
- user.save()
- Profile.objects.filter(user=user).update(passw=password, user=user, position=item[1],
- investment=item[2], email=item[3], ava=item[4], holding=item[5],
- company=item[6], cluster=item[7], area=item[8],total=item[9],
- ebitda=item[10], teamInvestment2=item[11], teamInvestment1=item[12],
- wheat_plant=item[13], rape_plant=item[14], soybean_plant=item[15],
- corn_plant=item[16], sunflower_plant=item[17], wheat_plant_price=item[18],
- rape_plant_price=item[19], soybean_plant_price=item[20], corn_plant_price=item[21],
- sunflower_plant_price=item[22], wheat_plant_productivity=item[23],
- rape_plant_productivity=item[24], soybean_plant_productivity=item[25],
- corn_plant_productivity=item[26], sunflower_plant_productivity=item[27],
- companyWeight=item[28])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement