Problems installing pyperclip module for python. Not recognised as a module.
Not able to install it from command line. Resolved by running pip install pyperclip by running command line as administrator. (Right-click on command line icon in start menu and select "run as administrator").
Showing posts with label automate the boring stuff with python. Show all posts
Showing posts with label automate the boring stuff with python. Show all posts
File management using openpyxl
When using openpyxl to load workbooks, ensure that your excel file is saved in the same folder as the .py file you are developing.
import openpyxl, pprintprint('Opening workbook... ')wb = openpyxl.load_workbook('censuspopdata.xlsx')sheet = wb.get_sheet_by_name('Population by Census Tract')Otherwise, the following "file not found" error will result:
"FileNotFoundError: [Errno 2] No such file or directory: 'censuspopdata.xlsx'"
TypeError: 'generator' object is not subscriptable
Error in chapter 12, which produces the following "TypeError: 'generator' object is not subscriptable" for the code below.
>>> import openpyxl
>>> wb = openpyxl.load_workbook('example.xlsx')
>>> sheet = wb.active
>>> sheet = wb.active
>>> sheet.columns[1]
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
sheet.columns[1]
TypeError: 'generator' object is not subscriptable
>>>
RESOLUTION:
Create a list for the sheet.colums:
list(sheet.columns)[1] to overcome the generator error - outdated method since python 2 apparently.
>>> import openpyxl
>>> wb = openpyxl.load_workbook('example.xlsx')
>>> sheet = wb.active
>>> sheet = wb.active
>>> sheet.columns[1]
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
sheet.columns[1]
TypeError: 'generator' object is not subscriptable
>>>
RESOLUTION:
Create a list for the sheet.colums:
list(sheet.columns)[1] to overcome the generator error - outdated method since python 2 apparently.
Subscribe to:
Posts (Atom)
Web Development: Organizing Files and Folders
When you begin to build your website, it's a very clever idea to organize your files and folders efficiently. You should have: A ...
-
Continuing our journey through Automate the Boring Stuff with Python's excel lessons, we came across the get_column_letter and column_in...
-
What are the meanings of the various types of averages in datasets? Mean == the "centre" ("center") of a dataset. ...
-
First, a warning. Don't get mixed-up between finding the percentage of x in a list and finding a percentile of x. I've already co...