Potentially useful code snippets
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 lines
636 B

import openpyxl as op
#Looks up spreadsheet values then splits them. Convenenient when
#getting forms that are badly formatted.
book = op.load_workbook('a.xlsx')
sheet = book.active
sheet['F1'].value = 'Last Name'
sheet['G1'].value = 'First Name'
for count, cell in enumerate(sheet['A']):
if count == 0 :
continue
else:
print(count, cell.value)
if cell.value:
split = cell.value.find(' ')
firstname = cell.value[:split]
lastname = cell.value[split+1:]
sheet['F'+str(count+1)] = lastname
sheet['G'+str(count+1)] = firstname
book.save('a.xlsx')