Browse Source

Added openpyxl example

master
Kashirigi 6 years ago
parent
commit
d394283a6e
  1. 20
      Python/openpyxl/cellValueSplitter.py

20
Python/openpyxl/cellValueSplitter.py

@ -0,0 +1,20 @@ @@ -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')
Loading…
Cancel
Save