Python Forum
Getting Cells from the Sheets "automate the boring stuff"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting Cells from the Sheets "automate the boring stuff"
#1
I am working through the exel chapter of Automate the Boring Stuff. I am typing exactly as the book is telling me on page 268 and getting an error message.
>>> import openpyxl
>>> wb = openpyxl.load_workbook('Example_Page267.xlsx')
>>> sheet = wb.get_sheet_by_name('Sheet1')
>>> sheet['A1']
<Cell 'Sheet1'.A1>
>>> sheet['A1'].value
datetime.datetime(2015, 5, 4, 13, 34)
>>> c = sheet['B1']
>>> c.value
'Apples'
>>> 'Row ' + int(c.row) + ',Column ' + c.column + ' is ' + c.value
i then get the following error
Traceback (most recent call last):
  File "<pyshell#54>", line 1, in <module>
    'Row ' + int(c.row) + ',Column ' + c.column + ' is ' + c.value
TypeError: can only concatenate str (not "int") to str
Reply


Messages In This Thread
Getting Cells from the Sheets "automate the boring stuff" - by Shafla - Sep-23-2019, 08:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Help using Google Sheets matheuspimenta 0 726 Dec-15-2022, 05:36 PM
Last Post: matheuspimenta
  How to loop through all excel files and sheets in folder jadelola 1 4,525 Dec-01-2022, 06:12 PM
Last Post: deanhystad
  Openpyxl-change value of cells in column based on value that currently occupies cells phillipaj1391 5 9,868 Mar-30-2022, 11:05 PM
Last Post: Pedroski55
  Run the code for some stuff it does not return me why Anldra12 3 2,873 Apr-19-2021, 02:01 PM
Last Post: Anldra12
  How can I iterate through all cells in a column (with merge cells) with openpyxl? aquerci 1 7,534 Feb-11-2021, 09:31 PM
Last Post: nilamo
  "Automate the Boring Stuff with Python" creating a path works but only for CMD promt Milos 2 2,888 Nov-28-2020, 01:08 PM
Last Post: Larz60+
  Unable to print stuff from while loop Nick1507 4 2,364 Sep-17-2020, 02:26 PM
Last Post: Nick1507
  identical cells in 2 different excel sheets python pandas esso 0 1,646 Jul-19-2020, 07:50 PM
Last Post: esso
  Copy certain cells into new workbook certain cells Kristenl2784 4 2,504 Jul-14-2020, 07:59 PM
Last Post: Kristenl2784
  How Do I Install Stuff for Python? CopBlaster 6 3,213 May-08-2020, 12:27 PM
Last Post: hussainmujtaba

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020