diff --git a/Python/openpyxl/cellValueSplitter.py b/Python/openpyxl/cellValueSplitter.py new file mode 100644 index 0000000..792bce4 --- /dev/null +++ b/Python/openpyxl/cellValueSplitter.py @@ -0,0 +1,20 @@ +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')